Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        public void Start()
        {
            lock (_mLockObject)
            {
                switch (this.Status)
                {
                case BackgroundPinControllerStatus.Stopped:
                    Console.WriteLine("starting pin controller thread");
                    this.Status       = BackgroundPinControllerStatus.Running;
                    this.WorkerThread = new Thread(this.Execute);
                    this.WorkerThread.IsBackground = true;
                    this.WorkerThread.Start();
                    break;

                default:
                    throw new System.InvalidOperationException("Cannot start a controller with the status '" + this.Status.ToString() + "'");
                }
            }
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        public void Stop()
        {
            lock (_mLockObject)
            {
                switch (this.Status)
                {
                case BackgroundPinControllerStatus.Running:
                    Console.WriteLine("stopping pin controller thread");
                    this.Status = BackgroundPinControllerStatus.Stopping;
                    while (this.WorkerThread.IsAlive)
                    {
                        Thread.Sleep(100);
                    }
                    this.WorkerThread = null;
                    this.Status       = BackgroundPinControllerStatus.Stopped;
                    break;

                default:
                    throw new System.InvalidOperationException("Cannot stop a controller with the status '" + this.Status.ToString() + "'");
                }
            }
        }
Beispiel #3
0
        /// <summary>
        ///
        /// </summary>
        public void Start()
        {
            lock (_lockObject)
            {
                switch (this.Status)
                {
                case BackgroundPinControllerStatus.Stopped:
                    Console.WriteLine("starting pin controller thread");
                    this.Status       = BackgroundPinControllerStatus.Running;
                    this.WorkerThread = new Thread(this.Execute)
                    {
                        IsBackground = true
                    };
                    this.WorkerThread.Start();
                    break;

                default:
                    throw new InvalidOperationException(
                              string.Format("Cannot start a controller with the status '{0}'", this.Status));
                }
            }
        }