IAsyncResult BeginGetContext(bool startListening) { EventTraceActivity eventTraceActivity = null; if (FxTrace.Trace.IsEnd2EndActivityTracingEnabled) { eventTraceActivity = EventTraceActivity.GetFromThreadOrCreate(true); if (TD.HttpGetContextStartIsEnabled()) { TD.HttpGetContextStart(eventTraceActivity); } } while (true) { Exception unexpectedException = null; try { try { if (ExecutionContext.IsFlowSuppressed()) { return(this.BeginGetContextCore(eventTraceActivity)); } else { using (ExecutionContext.SuppressFlow()) { return(this.BeginGetContextCore(eventTraceActivity)); } } } catch (HttpListenerException e) { if (!this.HandleHttpException(e)) { throw; } } } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } if (startListening) { // Since we're under a call to StartListening(), just throw the exception up the stack. throw; } unexpectedException = e; } if (unexpectedException != null) { this.Fault(unexpectedException); return(null); } } }