Exemplo n.º 1
0
        public void Stop()
        {
            if (_status == RunnableStatus.Stopped)
            {
                return;
            }

            try
            {
                _status = RunnableStatus.Stopping;

                lock (this)
                {
                    OnStop();
                }
            }
            finally
            {
                _status = RunnableStatus.Stopped;
            }
        }
Exemplo n.º 2
0
        public void Start(object context = null)
        {
            if (_status == RunnableStatus.Running)
            {
                return;
            }

            try
            {
                _status = RunnableStatus.Running;
                lock (this)
                {
                    OnStart(context);
                }
            }
            catch (Exception)
            {
                Stop();
                throw;
            }
        }