/// <summary> /// Stop the Outlook thread if required. /// </summary> private void StopThreadIfNeeded() { if (!IsThreadReady()) return; m_sessionStatus = OutlookSessionStatus.Stopping; Debug.Assert(m_thread != null); m_thread.RequestCancellation(); }
/// <summary> /// Start the Outlook thread if required. /// </summary> private void StartThreadIfNeeded() { if (!m_enabledFlag || m_sessionStatus != OutlookSessionStatus.Stopped) return; m_sessionStatus = OutlookSessionStatus.Listening; Debug.Assert(m_thread == null); m_thread = new WmOutlookThread(this); m_thread.Start(); }
/// <summary> /// Called when Outlook is connected. /// </summary> private void HandleConnectedToOutlook(UInt64 sessionID) { Logging.Log("HandleConnectedToOutlook(" + sessionID + ") called."); Debug.Assert(m_sessionStatus == OutlookSessionStatus.Listening); m_sessionStatus = OutlookSessionStatus.Open; m_sessionID = sessionID; KwmStateDate = DateTime.MaxValue; SendNewKwmStateInfos(); }
/// <summary> /// Called when Outlook is disconnected. /// </summary> private void HandleDisconnectedFromOutlook(Exception ex) { m_sessionStatus = OutlookSessionStatus.Listening; AbortPendingRequests(ex); }
/// <summary> /// Called when the Outlook thread has completed. 'ex' is null if the /// thread has been cancelled, otherwise it contains the reason why the /// thread has stopped. /// </summary> public void OnThreadCompletion(Exception ex) { Debug.Assert(m_thread != null); // The Outlook thread is not allowed to fail. if (ex != null) Base.HandleException(ex, true); // The thread has stopped. Debug.Assert(m_sessionStatus == OutlookSessionStatus.Stopping); m_sessionStatus = OutlookSessionStatus.Stopped; m_thread = null; // Notify the listeners. if (OnThreadCollected != null) OnThreadCollected(this, null); // Restart the thread if the broker is enabled. StartThreadIfNeeded(); }