public virtual bool Send(byte[] buffer, int ofs, int len) { Exception exception = null; SocketWorkContext context = null; lock (this) { context = this.context; } if (context == null) { exception = new InvalidOperationException("The job context does not exist and this operation is not allowed");; } else { return(context.Send(buffer, ofs, len)); } if (exception == null) { return(false); } else { throw exception; } }
public virtual void Run() { Exception exception = null; lock (this) { SocketWorkContext context = this.context; if (context != null) { exception = new InvalidOperationException("The current state does not allow duplicate start job tasks"); } else { context = new SocketWorkContext(this); this.context = context; } if (context != null) { context.Run(); } } if (exception != null) { throw exception; } }
public virtual void Abort() { SocketWorkContext context = this.context; if (context != null) { context.Abort(); } }
public virtual void Stop() { lock (this) { SocketWorkContext context = this.context; if (context != null) { context.Close(); } this.context = null; } }