Exemplo n.º 1
0
 /// <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();
 }
Exemplo n.º 2
0
 /// <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();
 }
Exemplo n.º 3
0
 /// <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();
 }
Exemplo n.º 4
0
 /// <summary>
 /// Called when Outlook is disconnected.
 /// </summary>
 private void HandleDisconnectedFromOutlook(Exception ex)
 {
     m_sessionStatus = OutlookSessionStatus.Listening;
     AbortPendingRequests(ex);
 }
Exemplo n.º 5
0
        /// <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();
        }