private static void OnWriteUpgradeBytes(IAsyncResult result) { if (!result.CompletedSynchronously) { ConnectionUpgradeHelper.InitiateUpgradeAsyncResult asyncState = (ConnectionUpgradeHelper.InitiateUpgradeAsyncResult)result.AsyncState; Exception exception = null; bool flag = false; try { if (asyncState.CompleteWriteUpgradeBytes(result)) { flag = asyncState.Begin(); } } catch (Exception exception2) { if (Fx.IsFatal(exception2)) { throw; } flag = true; exception = exception2; } if (flag) { asyncState.Complete(false, exception); } } }
private static void OnReadUpgradeResponse(object state) { ConnectionUpgradeHelper.InitiateUpgradeAsyncResult result = (ConnectionUpgradeHelper.InitiateUpgradeAsyncResult)state; Exception exception = null; bool flag = false; try { if (result.CompleteReadUpgradeResponse()) { flag = result.Begin(); } } catch (Exception exception2) { if (Fx.IsFatal(exception2)) { throw; } flag = true; exception = exception2; } if (flag) { result.Complete(false, exception); } }