void UnRegister() { lock (this) { // Only unregister one time if (registrar == null) { return; } // Kill worker thread if (lengthFromSTA != -1) { alive = false; SetEvent(hDoIndicate); // doIndicate.Set(); } registrar.UnRegister_(); registrar = null; } }
void UnRegister() { lock (this) { // Only unregister one time if (registrar == null) { return; } // Kill worker thread if (workerThreadInitialized == true) { alive = false; doIndicate.Set(); // SetEvent(hDoIndicate); GC.KeepAlive(this); workerThreadInitialized = false; } registrar.UnRegister_(); registrar = null; } }