void OnConnected(WatcherRequest request, Exception error) { if (this.Tcp == null || this.connectedAction == null) { throw new ObjectDisposedException($"{nameof(TcpConnect)} has already been disposed."); } try { this.connectedAction(this.Tcp, error); if (error == null) { this.Tcp.ReadStart(); } } catch (Exception exception) { ScheduleRequest.Log.Error("UV_CONNECT callback error.", exception); } finally { this.Dispose(); } }
internal StreamShutdown(StreamHandle streamHandle, Action <StreamHandle, Exception> completedAction) { Contract.Requires(streamHandle != null); streamHandle.Validate(); this.streamHandle = streamHandle; this.completedAction = completedAction; this.watcherRequest = new WatcherRequest( uv_req_type.UV_SHUTDOWN, this.OnCompleted, h => NativeMethods.Shutdown(h, this.streamHandle.InternalHandle), closeOnCallback: true); }
public TcpConnect(Tcp tcp, IPEndPoint remoteEndPoint, Action <Tcp, Exception> connectedAction) { Contract.Requires(tcp != null); Contract.Requires(remoteEndPoint != null); Contract.Requires(connectedAction != null); tcp.Validate(); this.Tcp = tcp; this.connectedAction = connectedAction; this.watcherRequest = new WatcherRequest( uv_req_type.UV_CONNECT, this.OnConnected, h => NativeMethods.TcpConnect(h, tcp.InternalHandle, remoteEndPoint)); }
void OnWriteCallback(WatcherRequest request, Exception error) { Log.Trace($"{nameof(WriteTask)} Write request callback, releasing resources."); try { // Free all resource before it can be recycled this.Release(); this.taskCallback?.Invoke(this, error); } catch (Exception exception) { Log.Error($"{nameof(WriteTask)} Write request callback error.", exception); // If exception is thrown, we cannot recyled this request this.Dispose(); } }
void OnCompleted(WatcherRequest request, Exception error) { Completed(this.completedAction, this.streamHandle, error); this.Dispose(); }