static void OnConnect(IAsyncResult result) { if (result.CompletedSynchronously) { return; } EstablishConnectionAsyncResult thisPtr = (EstablishConnectionAsyncResult)result.AsyncState; Exception completionException = null; bool completeSelf; try { completeSelf = thisPtr.HandleConnect(result); } #pragma warning suppress 56500 // [....], transferring exception to another thread catch (Exception e) { if (Fx.IsFatal(e)) { throw; } completeSelf = true; completionException = e; } if (completeSelf) { thisPtr.Cleanup(); thisPtr.Complete(false, completionException); } }
static void OnProcessConnection(IAsyncResult result) { if (result.CompletedSynchronously) { return; } EstablishConnectionAsyncResult thisPtr = (EstablishConnectionAsyncResult)result.AsyncState; Exception completionException = null; bool completeSelf; try { bool snapshotCollection = false; try { completeSelf = thisPtr.HandleProcessConnection(result); if (completeSelf) { snapshotCollection = true; } } catch (CommunicationException communicationException) { if (!thisPtr.newConnection) // CommunicationException is ok from our cache { DiagnosticUtility.TraceHandledException(communicationException, TraceEventType.Information); thisPtr.Cleanup(); completeSelf = thisPtr.Begin(); } else { completeSelf = true; completionException = communicationException; } } catch (TimeoutException timeoutException) { if (!thisPtr.newConnection) // TimeoutException is ok from our cache { if (TD.OpenTimeoutIsEnabled()) { TD.OpenTimeout(timeoutException.Message); } DiagnosticUtility.TraceHandledException(timeoutException, TraceEventType.Information); thisPtr.Cleanup(); completeSelf = thisPtr.Begin(); } else { completeSelf = true; completionException = timeoutException; } } if (snapshotCollection) { thisPtr.SnapshotConnection(); } } #pragma warning suppress 56500 // [....], transferring exception to another thread catch (Exception e) { if (Fx.IsFatal(e)) { throw; } completeSelf = true; completionException = e; } if (completeSelf) { thisPtr.Cleanup(); thisPtr.Complete(false, completionException); } }