コード例 #1
0
            static void OnConnect(TransportAsyncCallbackArgs args)
            {
                ConnectAsyncResult thisPtr = (ConnectAsyncResult)args.UserToken;

                if (args.Exception != null)
                {
                    thisPtr.Complete(args.CompletedSynchronously, args.Exception);
                }
                else
                {
                    thisPtr.transport = args.Transport;
                    thisPtr.Complete(args.CompletedSynchronously);
                }
            }
コード例 #2
0
                static void OnSocketConnect(IAsyncResult result)
                {
                    if (result.CompletedSynchronously)
                    {
                        return;
                    }

                    ConnectAsyncResult thisPtr = (ConnectAsyncResult)result.AsyncState;

                    Exception completionException = null;
                    bool      completeSelf        = false;

                    try
                    {
                        completeSelf = thisPtr.CompleteSocketConnect(result);
                    }
                    catch (Exception e)
                    {
                        completeSelf        = true;
                        completionException = e;
                    }

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