Sunday, June 9, 2013

Thread safe Dispose + Finalize



Looks pretty good except


if (this.Disposed)
return;
<!-- here is the problem-->
lock (this._lock)
{



There can be the situation when this.Disposed is changed between checks.

As an example, you can use


lock(this._lock)
{
if(_this.disposed)
return;
....
}






No comments:

Post a Comment