static void OnWrite(IAsyncResult result) { if (result.CompletedSynchronously) { return; } SendAsyncResult thisPtr = (SendAsyncResult)result.AsyncState; Exception completionException = null; try { thisPtr.CompleteWrite(result); } catch (Exception e) { completionException = e; } thisPtr.Complete(false, completionException); }