SendOrPostCallback does not run in the same thread when calling SynchronizationContext.Post()
For my question I have prepared a C# Fiddle and when you click “Run” there few times, you will see the exception in the log.
Does a thread lingering within an instance member method keep the instance alive if all other references are dropped?
Pretty simple yes/no question:
Why thread safety is listed as a benefit of immutability?
I was reading about Records
in C# and read that they are immutable. And thread safety is written as a benefit of immutability. How immutability provides thread safety. I tried a code sample claiming to provide predictable results by using Records
because they are immutable rather than using shared mutable object. I tried the code and the results were unpredictable:
Do Monitor.Pulse and Monitor.Wait enter kernel mode?
Monitor.Wait()
and Monitor.Pulse()
are supposed to be more performant than using EventWaitHandle
derived classes such as ManualResetEvent
per this source.