thread safe in Dispose method
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?
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.
protected virtual void Dispose(bool disposing)
if ((false == disposed) && (true == disposing))
// some operations here
disposed = true;
thanks in advance,