0

What is the risks of using Form1.CheckForIllegalCrossThreadCalls = false If i decide to use Thread to reach form controls ??

user2880188
  • 33
  • 1
  • 7
  • This question may already have an answer here: [Please Refer][1] [1]: http://stackoverflow.com/questions/13345091/c-sharp-checkforillegalcrossthreadcalls – pravprab Jan 03 '14 at 08:59

2 Answers2

1

So you might do "illegal cross thread calls" and wont be warned. The behavior is undefined, your application will randomly crash (if you are lucky).

Avoid using the same instance of a mutable object on different threads. To deal with GUI objects in a multithread application, see this : How to update the GUI from another thread in C#?

Community
  • 1
  • 1
Guillaume
  • 12,824
  • 3
  • 40
  • 48
0

If you need to use the Thread to reach the form control then you should consider using the Control.Invoke method. You can find the documentation of Control.Invoke here

Ramashankar
  • 1,598
  • 10
  • 14
  • I know that , but i have a curiosity about this property (CheckForIllegalCrossThreadCalls) – user2880188 Jan 03 '14 at 09:14
  • @user2880188: If you set Form1.CheckForIllegalCrossThreadCalls = false, system will ignore the illegal thread calls being made to access/modify the control. The result of cross thread access to control is undefined. many times you won't notice much of the problem but when it breaks, it is really hard to figure out the cause of the trouble. – Ramashankar Jan 03 '14 at 09:25