Hi, First I would like to say I am VERY new to programming and still dont understand alot. Please be patient with me.
Im trying to have have an object on my UI refresh on a seperate thread. I have read about 100 tutorials about multithreading and still dont completely understand it. Im using zedgraph and need to refresh it on a seperate thread because it messes up my timings.
Here is why, I need to acurately have a process timed and the refresh or invalidate of zedgraph is slow and fluctuates. Im using the stopwatch and a tight loop (I know its bad) as my timer because I need accurate timing and thread.sleep isnt accurate below @20ms, Im working with between 5ms and 70ms.
Im confused with delegates and invoking, I mean completely lost. I dont understand how invoke works and how to use it and same with delegates. ANY help would be appreciated.
Thansk John
Loading
CodyPosted Apr 1, 2010, 6:54 PM
private void SetValue(object property, object value, Control control)
{
if (control.InvokeRequired)
{
this.Invoke(new SetValueCallback(SetText), new object[] { property, value, control });
}
else
{
property = value;
}
}
Sam HobbsPosted Mar 13, 2010, 3:42 AM
Add the following as a member of the from:
Also add the following method to the form:
John WibergPosted Mar 12, 2010, 7:16 PM
The code you included is the best example Ive seen so far. The threads are in the same class, Is it more advisable to create another discrete thread or use the backroundworker dowork? The second thread will/should remain active during the time the main thread is active.
Im sorry if I confuse you, im really new to programming windows programs, Im an embedded c programmer and a lot of these things are new to me.
Sam HobbsPosted Mar 11, 2010, 9:54 PM
Let's assume you need to update a textbox called textBox1 in a form. Let's also assume that your other thread is executing within the form's class, although I get the impression that is not true. Please explain how the other thread is able to access the form if the thread is not in the form's class. If you don't understand, then say so.
Add the following as a member of the from:
Also add the following method to the form: Then when you need to update textBox1 from the thread, call SetText with the string for textBox1.