private void DisconnectCallback(IAsyncResult ar) { // Retrieve the socket from the state object. Socket socket = (Socket)ar.AsyncState; try { // Complete the disconnect. socket.EndDisconnect(ar); } catch (Exception exc) { if (OnError.GetInvocationList().Length > 0) { OnError(this, exc); } } // Signal that the disconnect is complete. _disconnectDone.Set(); // Bubble the event if (OnDisconnected.GetInvocationList().Length > 0) { OnDisconnected(this, _socket.Connected); } }
public void Unsubscribe(DisconnectionDelegate @delegate) { if (OnDisconnected.GetInvocationList().Contains(@delegate)) { OnDisconnected -= @delegate; } }
void socketComm_OnDisconnected(object sender, bool connected) { if (connected && OnError.GetInvocationList().Length > 0) { OnError(this, new Exception("Failed to disconnect on command port.")); } //throw event if (OnDisconnected.GetInvocationList().Length > 0) { OnDisconnected(sender, connected); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void connection_OnDisconnected(object sender, nsoftware.IPWorks.IpportDisconnectedEventArgs e) { if (OnDisconnected != null && OnDisconnected.GetInvocationList() != null) { OnDisconnected(e.StatusCode, e.Description); } if (e.StatusCode != 0) { Status = CONNECTION_LOST; } else { Status = DISCONNECTED; } }