Fody/Janitor

Prevent racing condition at dispose time

johnsimons opened this issue · 1 comments

In a multi-threaded situation the dispose flag should be set at the end of the Dispose method.

Currently the Dispose is injected with the following code:

public void Dispose()
{
   if (Interlocked.Exchange(ref this.disposeSignaled, 1) != 0)
        return;

   //Disposing code
}

The issue is that if you have a class that receives events in different threads, you can't prevent it from receiving an ObjectDisposedException.

fixed in 0.4.0.0