/// <summary>
        ///     Stop the RS232 polling loop
        /// </summary>
        public void StopPollingLoop()
        {
            lock (_mutex)
            {
                if (!_isRunning)
                {
                    Logger?.Error("{0} Polling loop is not running, ignoring stop command", GetType().Name);
                    return;
                }

                _isRunning = false;
            }

            Logger?.Debug("{0} Stopping polling loop...", GetType().Name);

            if (!_rs232Worker.Join(TimeSpan.FromSeconds(10)))
            {
                Logger?.Error("{0} Failed to stop polling loop", GetType().Name);
            }
            else
            {
                Logger?.Info("{0} Polling loop stopped", GetType().Name);
            }

            try
            {
                SerialProvider.Close();
            }
            catch (Exception ex)
            {
                Logger?.Error("{0} Unable to close serial provider: {1}", GetType().Name, ex.Message);
            }
        }
예제 #2
0
파일: Blaze.cs 프로젝트: vipsaini/Blaze
 public void Close()
 {
     _provider.Close();
 }