Exemplo n.º 1
0
        void StartDispatchSession(ListenerSessionConnection session)
        {
            if (TD.DispatchSessionStartIsEnabled())
            {
                TD.DispatchSessionStart(session.EventTraceActivity);
            }

            IAsyncResult dispatchAsyncResult = null;

            try
            {
                dispatchAsyncResult = session.WorkerProcess.BeginDispatchSession(session, dispatchSessionCompletedCallback, session);
            }
            catch (Exception exception)
            {
                if (Fx.IsFatal(exception))
                {
                    throw;
                }

                DiagnosticUtility.TraceHandledException(exception, TraceEventType.Warning);

                if (session.WorkerProcess.IsRegistered)
                {
                    // Add the worker back to the queue.
                    EnqueueWorkerAndDispatch(session.WorkerProcess, false);
                }
            }

            if (dispatchAsyncResult != null && dispatchAsyncResult.CompletedSynchronously)
            {
                CompleteDispatchSession(dispatchAsyncResult);
            }
        }