|
Sorry! My bad, over-eager with the cut and paste.
Should be
dataGridTicketInformation.DoubleClick += new System.EventHandler(dataGridTicketInformation_DoubleClick);
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi.
How can we write a program for a Core 2 due CPU ?
I mean, a program that divides the process between cores !
Thanks
|
|
|
|
|
|
You can use multi-threading, but realize that the OS itself and the internal operations of .NET are already doing that. Also be aware that multi-threading for the sake of multi-threading may add complexity for no reason and cause your program to actually run slower.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
I want to add numbers from 1 to 12 to clock..i got positions for lines..but i don't know how to add numbers using same positions as for lines..help plz!?
Thanks
|
|
|
|
|
I strongly recommend you sketch it out on a piece of paper. From there you should be able to work out a way of calculating the co-ordinates you need to draw the text at. A useful function (assuming you're using a Graphics class to draw) is Graphics.MeasureString , which will help you line things up properly. The rest will be a bit of trial and error.
|
|
|
|
|
so there is not such function that would add text to form with x and y coordinates?
|
|
|
|
|
Hi,
you can paint lines, rectangles, ovals, images and text strings using the Graphics class inside a Paint handler.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
It is excellent to try to work this out for yourself, but there are sooooooo many examples of Analogue Clock out on the web that you should really Google for any problems. If memory serves there is even an example on MSDN.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi,
I'm using C#.net 3.0 to develop an application on digital watermarking.I'm using FrameGrabber class which I have found on this site.What the class is doing-it is getting the constituent frames in the Bitmap format (*.bmp) from the given video file.Now the problem is that there is no way to stop the function in the middle of execution i.e. if I want to stop the function from extracting further more frames I have to shutdown the application.Now I want to put a function on Button(STOP) such that when I press the button it will stop the function from further execution and all the frames so far extracted should remain in the destined folder.Can anybody please tell me how to do this.
This is the code for Button- Extact frames
[code]
private void button43_Click(object sender, EventArgs e)//to extract frame
{
string outPath = txtExtBitmap.Text;//path of destination folder where the extracted frames are kept
System.IO.Directory.CreateDirectory(outPath);
if (fg != null)
{
foreach (FrameGrabber.Frame f in fg)
{
using (f)
{
picBoxFrame.Image = (Bitmap)f.Image.Clone();
f.Image.Save(System.IO.Path.Combine(outPath, "frame" + f.FrameIndex + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);//save each frame in *.bmp format
Application.DoEvents();
}
if (fg == null)
{
return;
}
}
}
[/code]
Thank You!!
|
|
|
|
|
You're going to have to move the code that iterates through each frame to a background thread (look into the BackgroundWorker component) and modify the loop so that it checks a flag to know that it has to stop.
Get rid of the Application.DoEvents call when you move the code to the background thread. Like using "Goto" in your code, it's the second reason why a kitten gets punched in the face every time it's used.
|
|
|
|
|
Dave Kreskowiak wrote: a kitten gets punched in the face
I wanna see that!
|
|
|
|
|
PIEBALDconsult wrote: I wanna see that!
As Dave said, use either Application.DoEvents or goto
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Got something against kittens??
|
|
|
|
|
Hi,
Thanks for your reply
I used this code but it is still showing error highlighting fThread.Interrupt() ---Object reference not set to an instance of an object.Now what changes should I do in order to make this code work
[code]
private void frameExtract()//function to extract frames
{
string outPath = txtExtBitmap.Text;
System.IO.Directory.CreateDirectory(outPath);
if (fg != null)
{
foreach (FrameGrabber.Frame f in fg)
{
using (f)
{
picBoxFrame.Image = (Bitmap)f.Image.Clone();
f.Image.Save(System.IO.Path.Combine(outPath, "frame" + f.FrameIndex + ".bmp"), System.Drawing.Imaging.ImageFormat.Bmp);
Application.DoEvents();
}
if (fg == null)
{
return;
}
}
}
}
public void ThreadProc()
{
try
{
MethodInvoker mi = new MethodInvoker(this.frameExtract);
this.BeginInvoke(mi);
}
catch (ThreadInterruptedException e)
{
Console.WriteLine("Interruption",e);
}
catch (Exception we)
{
Console.WriteLine("Exceptiom",we);
}
}
private void button43_Click(object sender, EventArgs e)//Extract button
{
fThread = new Thread(new ThreadStart(ThreadProc));
fThread.IsBackground = true;
fThread.Start();
}
private void button44_Click(object sender, EventArgs e)//Stop Button
{
fThread.Interrupt();
fThread = null;
}
[\code]
|
|
|
|
|
Payam Rastogi wrote: I used this code but it is still showing error highlighting fThread.Interrupt() ---Object reference not set to an instance of an object.
Of course! fThread only exists inside your button43 Client handler. The variable can't be seen anywhere else in your code.
And why are you calling Interrupt?? Inside your looping thread code you would check for a flag that says it should stop. You shouldn't be abruptly stopping the thread before it can do any cleanup work it needs to.
|
|
|
|
|
This is always a problem with long running synchronous (blocking) event handlers.
The easiest way of the top of my head:
Add a background worker component and set WorkerSupportsCancellation to true then call RunWorkerAsync() in the button_Click event handler. Put the code above in the DoWork event handler, then you can check the CancellationPending on each iteration.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
How could I show the total interest paid and the average interest gained each year?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Project1
{
class Program
{
public static void Main()
{
Console.Write("Enter principal: ");
decimal p = Convert.ToDecimal(Console.ReadLine());
if (p < 0)
{
Console.WriteLine("Principal cannot be negative");
p = 0;
}
Console.Write("Enter interest rate: ");
decimal i = Convert.ToDecimal(Console.ReadLine());
if (i < 0)
{
Console.WriteLine("Interest cannot be negative");
i = 0;
}
Console.Write("Enter time (in years): ");
int years = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("\nPrincipal = " + p
+ "\nInterest = " + i + "%"
+ "\nTime = " + years + " years\n");
Console.WriteLine("\n\nYear\tRate\t Amount\tInterest\tNew Amount");
Console.WriteLine("===========================================================");
int year = 1;
while (year <= years)
{
decimal interestPaid = p * (i / 100);
decimal amount = p + interestPaid;
p += interestPaid;
p = decimal.Round(p, 2);
interestPaid = decimal.Round(interestPaid, 2);
amount = decimal.Round(amount, 2);
Console.WriteLine(year + "\t" + i + "%\t" + ((p - interestPaid).ToString().PadLeft(10)) + "\t" + interestPaid.ToString().PadLeft(8) + "\t" + p.ToString().PadLeft(8));
year++;
}
}
}
}
|
|
|
|
|
yes
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I don't think the other answer you got really fit the question.
ctreed728 wrote: How could I show the total interest paid and the average interest gained each year?
By referring to your course notes, talking to your teacher if you get stuck, stepping through the code if you need to, and breaking down the task into small steps you can turn into code.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
Hi All,
I'm just working on a WPF desktop database app and I may have a scenario that I think could benefit from the occasional forced garbage collection. The only reason I'm really venturing down this path is that my user base are pretty savvy types and memory is *always* at a premium.
When the app starts up it's consuming around 50Mb of RAM nothing to complain about. However, during certain searches on the database this memory usage can escalate to 150Mb+. Say search 1 returns 60,000 records from the Db and in this scenario the memory jumps to 150Mb and a short time later another seach might only return a few hundred samples. I'm seeing the memory still at around the 150Mb mark whereas I want this to be immediately reduced to reflect the required RAM needed to represent that smaller search result set.
Is it worth exploring a forced GC.Collect() . I've been doing plenty of reading and it seems like the message is a little mixed on this. Some people seem to use it regularly, some say never use it. Microsoft seem to say leave it up to the CG to decide, but as I illustrated above I want to free that RAM as quickly as possible.
Thanks,
|
|
|
|
|
Jammer wrote: Is it worth exploring a forced GC.Collect().
Unless you really know what you're doing and why, no, it's not.
Jammer wrote: memory jumps to 150Mb and a short time later another seach might only return a few hundred samples. I'm seeing the memory still at around the 150Mb mark
Don't tell me you used TaskManager to determine this! It's lying to you. TM doesn't show you how much memory your app is actually using - it's showing you how much the .NET CLR has allocated to your app - including the rest of the managed heap that your app isn't using. Use PerformanceMonitor and the .NET Memory counters to see your apps actual usage.
You really don't have to worry about memory unless your app is really hanging onto it and not releasing it back to the managed pool. The .nET CLR does a very good job of managing the memory and returning whatever it can back to Windows, whenver Windows needs it.
Allocating object out of the managed pool is always faster than waiting for the CLR to get another block of memory from Windows, adding it to the Managed Heap, then allocating your object. That's why the CLR maintains a pool of memory that your app hasn't used yet.
Jammer wrote: but as I illustrated above I want to free that RAM as quickly as possible.
You don't have to. It's handled automatically whenever the CLR determines that is has an excessive amount of unused memory in the managed pool or Windows needs it back.
|
|
|
|
|
Dave Kreskowiak wrote: Unless you really know what you're doing and why, no, it's not.
Well, I obviously don't!
Dave Kreskowiak wrote: Don't tell me you used TaskManager to determine this! It's lying to you.
I did ... my bad!
Dave Kreskowiak wrote: Use PerformanceMonitor and the .NET Memory counters to see your apps actual usage.
Ok, will look into this now. I blatantly didn't do enough reading on this. Thanks for this input Dave, much appreciated.
Cheers,
|
|
|
|
|
I didn't mean to be nasty to you.
It's the third time this week I've had to describe how the .NET memory manager works. Everyone thinks that TaskManager is the "end all be all" of memory statistics, when it's not. Noone ever remembers that PerfMon even exists let alone that it can tell you FAR more about what's going on, and more accurately.
The last time I described this, the person didn't believe that TM could lie so badly. "yeah, TM is telling you that the app is using 100MB+ of RAM, but PerfMon says it's really using 18MB." Which one are you going to believe?
|
|
|
|
|
Dave Kreskowiak wrote: Big Grin I didn't mean to be nasty to you.
Hey Chap,
I didn't think you were. I've only been a .NETter for a little over a year and have a STACK ('scus the pun!) to learn yet.
I totally appreciate your input.
Cheers,
|
|
|
|