Hello everyone,
Here is my code for Dispose method. Currently, I am thinking whether it is necessary to make it thread safe by adding a lock to prevent two threads to execute Dispose methods at the same time?
Notes:
1. disposing is used to indicate explicit call to Dispose or implicit call from Finalizer;
2. disposed is used to indicate whether current instance is Disposed or not, to prevent from disposing again. The thread safety consideration is used to protect this variable.
[Code]
protected virtual void Dispose(bool disposing)
{
lock (DisposeLock)
{
if ((false == disposed) && (true == disposing))
{
// some operations here
disposed = true;
}
}
}
[/Code]
thanks in advance,
George