In one thread (thread2) I have changed a value e.g.
CheckSuccess = false;
Now the main thread (thread1 – GUI / Form) does not pickup the change, how would it be possible to “propogate” the changes around all threads?
I was under the impression that threads should manipulate the data, not work on seperate instances (unless told to do so)
It seems like a Race Condition. To avoid this you should synchronize an access to the shared variables.
volatilekeyword.If
CheckSuccessis a property (which will be translated to a method call) you can use lock() statement:If
CheckSuccessis a property of UI control and you want changing it from a worker thread – you should use special techniques to push changes from a worker to the UI thread, it depends on which framework you are using WinForms of WPF.PS:
Also if you have multiple threads reading a value and few threads writing (basically reads more often than writing) you may find useful ReaderWriterLock