Пример #1
0
        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;
            }
        }
Пример #2
0
        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;
            }
        }
Пример #3
0
        public virtual void Abort()
        {
            SocketWorkContext context = this.context;

            if (context != null)
            {
                context.Abort();
            }
        }
Пример #4
0
 public virtual void Stop()
 {
     lock (this)
     {
         SocketWorkContext context = this.context;
         if (context != null)
         {
             context.Close();
         }
         this.context = null;
     }
 }