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); } }
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); } }
// 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), }; }
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); } }
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); }
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); } }
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(); } } }
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); } }
public IConnection EndConnect(IAsyncResult result) { Socket socket = ConnectAsyncResult.End(result); return(this.CreateConnection(socket)); }
public TransportBase EndConnect(IAsyncResult result) { return(ConnectAsyncResult.End(result)); }
internal static IOamAsyncResult ConnectAsyncResult2IOamAsyncResult(ConnectAsyncResult car) { return(car); }
private IAsyncResult BeginConnect(ConnectParams @params, AsyncCallback asyncCallback, object asyncState) { ThrowIfAlreadyConnectedOrAsyncConnectRunning(); connectAsyncResult = new ConnectAsyncResult(); connectAsyncResult.BeginConnect(@params, asyncCallback, asyncState); return connectAsyncResult; }
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; } }
protected override void OnEndOpen(IAsyncResult result) { ConnectAsyncResult.End(result); }
public IConnection EndConnect(IAsyncResult result) { return(ConnectAsyncResult.End(result)); }