コード例 #1
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);
                    }
                }
コード例 #2
0
ファイル: MainProgram.cs プロジェクト: saintnever/impinjR420
        static void OnConnectAsyncComplete(ImpinjReader reader, ConnectAsyncResult result, string errorMessage)
        {
            // This event handler is called asynchronously
            // when the connection attempt has completed.

            // Check the result of the connection attempt
            if (result == ConnectAsyncResult.Success)
            {
                // Successfully connection to the reader. Now configure  and start it.
                Console.WriteLine("Successfully connected to {0}", reader.Address);
                reader.ApplyDefaultSettings();
                Console.WriteLine("Starting reader...");
                //reader.Start();
                SetReport(reader);
                // Wait for the user to press enter.
                Console.WriteLine("Press enter to exit.");
                Console.ReadLine();
                textWriter.Close();

                //cleanup
                reader.Stop();
                reader.Disconnect();
                Console.WriteLine("Reader stopped. Press enter to exit.");
            }
            else
            {
                // Failed to connect to the reader
                Console.WriteLine("Failure while connecting to {0} : {1}", reader.Address, errorMessage);
            }
        }
コード例 #3
0
ファイル: ClientNetwork.cs プロジェクト: talentxp/Network
        // block api
        public void Connect()
        {
            if (Connected)
            {
                return;
            }

            Log.Info("BeginReceive sysSocket.Connect(hostIp, hostPort);");
            try
            {
                sysSocket.Connect(hostIp, hostPort);
            }
            catch (Exception e)
            {
                Log.Error("ClientNetwork BeginReceive throw exp:{0}", e);
                defferedConnected = new ConnectAsyncResult()
                {
                    Ex = e,
                };

                return;
            }

            defferedConnected = new ConnectAsyncResult()
            {
                Conn = new Connector(sysSocket, 0),
            };
        }
コード例 #4
0
ファイル: ClientNetwork.cs プロジェクト: talentxp/Network
        public void Poll()
        {
            try
            {
                if (defferedConnected != null)
                {
                    connector = defferedConnected.Conn;
                    connector.BeginReceive();

                    // notify
                    if (ConnectorConnected != null)
                    {
                        ConnectorConnected(defferedConnected.Conn, defferedConnected.Ex);
                    }

                    defferedConnected = null;
                }

                RefreshMessageQueue();
                RefreshClient();
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
コード例 #5
0
        public override IAsyncResult BeginConnect(System.Net.EndPoint endPoint, AsyncCallback callback, Object state)
        {
            ConnectAsyncResult lWrapper = new ConnectAsyncResult(callback, state);

            this.fInnerConnection.BeginConnect(endPoint, lWrapper.ConnectionConnect, this);

            return(lWrapper);
        }
コード例 #6
0
 private static void Reader_ConnectAsyncComplete(ImpinjReader reader, ConnectAsyncResult result, string errorMessage)
 {
     if (result == ConnectAsyncResult.Success)
     {
         reader.ApplyDefaultSettings();
         reader.Start();
         Console.WriteLine("Started...");
     }
     else
     {
         Console.WriteLine(errorMessage);
     }
 }
コード例 #7
0
            static void OnConnect(TransportAsyncCallbackArgs args)
            {
                ConnectAsyncResult thisPtr = (ConnectAsyncResult)args.UserToken;

                if (!thisPtr.CompleteSelf(args.CompletedSynchronously, args.Exception))
                {
                    if (args.Transport != null)
                    {
                        // completed by timer
                        args.Transport.Abort();
                    }
                }
            }
コード例 #8
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);
                }
            }
コード例 #9
0
        public IConnection EndConnect(IAsyncResult result)
        {
            Socket socket = ConnectAsyncResult.End(result);

            return(this.CreateConnection(socket));
        }
コード例 #10
0
 public TransportBase EndConnect(IAsyncResult result)
 {
     return(ConnectAsyncResult.End(result));
 }
コード例 #11
0
 internal static IOamAsyncResult ConnectAsyncResult2IOamAsyncResult(ConnectAsyncResult car)
 {
     return(car);
 }
コード例 #12
0
ファイル: ImapClient.cs プロジェクト: pengyancai/cs-util
        private IAsyncResult BeginConnect(ConnectParams @params,
                                      AsyncCallback asyncCallback,
                                      object asyncState)
        {
            ThrowIfAlreadyConnectedOrAsyncConnectRunning();

              connectAsyncResult = new ConnectAsyncResult();
              connectAsyncResult.BeginConnect(@params, asyncCallback, asyncState);

              return connectAsyncResult;
        }
コード例 #13
0
ファイル: ImapClient.cs プロジェクト: pengyancai/cs-util
        public void EndConnect(IAsyncResult asyncResult)
        {
            if (asyncResult == null)
            throw new ArgumentNullException("asyncResult");
              if (asyncResult != connectAsyncResult)
            throw new ArgumentException("invalid IAsyncResult", "asyncResult");

              if (connectAsyncResult.EndConnectCalled)
            throw new InvalidOperationException("EndConnect already called");

              try {
            SetSession(connectAsyncResult.EndConnect());
              }
              finally {
            connectAsyncResult = null;
              }
        }
コード例 #14
0
 protected override void OnEndOpen(IAsyncResult result)
 {
     ConnectAsyncResult.End(result);
 }
コード例 #15
0
 public IConnection EndConnect(IAsyncResult result)
 {
     return(ConnectAsyncResult.End(result));
 }