I'd like to know if the executing thread is the one that created a given control instance (to prevent cross-thread if it's not). Is that possible ?
That's it ! Thank you.
Julien
2010-06-06 08:31:20
+1
A:
Check for control.InvokeRequired flag. if it is true, use the control.Invoke function to perform the operation.
Here is an article which looks in to the different scenarios in detail: http://weblogs.asp.net/justin_rogers/articles/126345.aspx
NimsDotNet
2010-06-06 08:26:07
A:
It is a good idea also to set Control::CheckForIllegalCrossThreadCalls to true in the beginning of the program, to get predictable crash in the case of incorrect cross-thread call.
Alex Farber
2010-06-06 08:29:35
A:
A great article (in my opinion) is the one available at http://www.albahari.com/threading/. It goes over all that you need to know about threading in C#, from Mutex to lock to Control.Invoke. I myself came from the Java world, and thought that C# threads and synchronization was the same, but this web page set me straight. :-)
Patrick
2010-06-06 09:40:37