C# and thread-safety of a bool
A little bit late but should be useful to the others. You can implement your own thread safe boolean in the following way: // default is false, set 1 for true. private int _threadSafeBoolBackValue = 0; public bool ThreadSafeBool { get { return (Interlocked.CompareExchange(ref _threadSafeBoolBackValue, 1, 1) == 1); } set { if (value) Interlocked.CompareExchange(ref … Read more