//release resources private void Cleanup(bool fromDispose) { MutexPool.Return(mutexWrapper_); mutexWrapper_ = null; beenDisposed_ = true;//set flag to show it has been disposed for (int i = 1;i<threadList.Count; i++) { if (threadList[i].ThreadState != ThreadState.Unstarted)//if not unstarted threadList[i].Join();//stop cleanly } }
//static method to return to pool internal static void Return(MutexWrapper mutexWrapper) { mutexWrapper.inuse = false;//used for troubleshooting mutexWrapper.mutex = null; //make this mutex available for garbage collection }
//release resources private void Cleanup(bool fromDispose) { MutexPool.Return(mutexWrapper_); mutexWrapper_ = null; beenDisposed_ = true;//set flag to show it has been disposed }
public Communicator() { mutexWrapper_ = MutexPool.Fetch(); beenDisposed_ = false; threadList = new List<Thread>();//will keep track of threads for cleanup later }
public Communicator() { mutexWrapper_ = MutexPool.Fetch(); beenDisposed_ = false; }