/// <summary> /// Dispose ucma helper. /// </summary> /// <param name="disposing">True => clean up managed resources</param> protected virtual void Dispose(bool disposing) { if (!m_disposed) { if (disposing) { ManualResetEvent waitHandle = m_allDone; m_allDone = null; if (waitHandle != null) { waitHandle.Close(); } TimerWheel timerWheel = m_timerWheel; if (timerWheel != null) { timerWheel.Dispose(); } lock (typeof(UcmaHelper)) { StaticInstance = null; } } m_cleanupNeeded = false; m_disposed = true; } }
/// <summary> /// Gets static instance. /// </summary> /// <returns>static instance.</returns> public static UcmaHelper GetInstance() { lock (typeof(UcmaHelper)) { if (StaticInstance == null) { StaticInstance = new UcmaHelper(); } return(StaticInstance); } }
/// <summary> /// Method to shutdown and clean up collaboration platform. /// </summary> public void Stop() { lock (m_syncRoot) { if (m_cleanupNeeded) { m_cleanupNeeded = false; Helper.Logger.Info("Stopping ucma platform"); var allDone = m_allDone; if (allDone != null) { allDone.Reset(); } this.Cleanup(); //Wait for all operations to complete. if (allDone != null) { bool succeeded = m_allDone.WaitOne(UcmaHelper.MaxTimeoutInMillis, false /*exitContext*/); if (!succeeded) { Helper.Logger.Info("Shutdown did not complete in expected time."); } allDone.Close(); } TimerWheel timerWheel = m_timerWheel; if (timerWheel != null) { timerWheel.Dispose(); } lock (typeof(UcmaHelper)) { StaticInstance = null; } } } }