Example #1
0
                static void OnOpen(IAsyncResult result)
                {
                    if (result.CompletedSynchronously)
                    {
                        return;
                    }

                    SendAsyncResult thisPtr = (SendAsyncResult)result.AsyncState;

                    Exception completionException = null;
                    bool      completeSelf        = false;

                    try
                    {
                        thisPtr.CompleteOpen(result);
                        completeSelf = thisPtr.SendMessage();
                    }
#pragma warning suppress 56500 // Microsoft, transferring exception to another thread
                    catch (Exception e)
                    {
                        if (Fx.IsFatal(e))
                        {
                            throw;
                        }

                        completeSelf        = true;
                        completionException = e;
                    }

                    if (completeSelf)
                    {
                        thisPtr.Cleanup(completionException == null);
                        thisPtr.Complete(false, completionException);
                    }
                }