Пример #1
0
        private void HandleRemoteScannerEvent(RemoteScannerEventType eventType)
        {
            lock (s_remoteScannerEventSync)
            {
                _lastRemoteScannerEvent = eventType;
            }
            if (!Monitor.TryEnter(s_handleRemoteScannerEventSync, 100))
            {
                return;
            }
            try
            {
                _scannerManager.StopScanning();
                lock (s_remoteScannerEventSync)
                {
                    switch (_lastRemoteScannerEvent)
                    {
                    case RemoteScannerEventType.Connected:
                        _logger.LogVerbose(Message.SyncRemoteScannerConnectedEventRaise);
                        RemoteScannerConnected.RaiseEvent(this);
                        break;

                    case RemoteScannerEventType.Disconnected:
                        _logger.LogVerbose(Message.SyncRemoteScannerDisconnectedEventRaise);
                        RemoteScannerDisconnected.RaiseEvent(this);
                        break;

                    case RemoteScannerEventType.WaitForInitialization:
                        _logger.LogVerbose(Message.SyncRemoteScannerWaitForInitializationEventRaise);
                        RemoteScannerWaitForInitialization.RaiseEvent(this);
                        break;

                    case RemoteScannerEventType.ExitFromMenu:
                        _logger.LogVerbose(Message.SyncRemoteScannerExitFromMenuEventRaise);
                        RemoteScannerExitFromMenu.RaiseEvent(this);
                        break;
                    }
                    Thread.Sleep(TimeSpan.FromSeconds(1));
                }
            }
            finally
            {
                Monitor.Exit(s_handleRemoteScannerEventSync);
            }
        }
Пример #2
0
 private void HandleRemoteScannerEvent(RemoteScannerEventType eventType)
 {
     lock (s_remoteScannerEventSync)
     {
         _lastRemoteScannerEvent = eventType;
     }
     if (!Monitor.TryEnter(s_handleRemoteScannerEventSync, 100))
         return;
     try
     {
         _scannerManager.StopScanning();
         lock (s_remoteScannerEventSync)
         {
             switch (_lastRemoteScannerEvent)
             {
                 case RemoteScannerEventType.Connected:
                     _logger.LogVerbose(Message.SyncRemoteScannerConnectedEventRaise);
                     RemoteScannerConnected.RaiseEvent(this);
                     break;
                 case RemoteScannerEventType.Disconnected:
                     _logger.LogVerbose(Message.SyncRemoteScannerDisconnectedEventRaise);
                     RemoteScannerDisconnected.RaiseEvent(this);
                     break;
                 case RemoteScannerEventType.WaitForInitialization:
                     _logger.LogVerbose(Message.SyncRemoteScannerWaitForInitializationEventRaise);
                     RemoteScannerWaitForInitialization.RaiseEvent(this);
                     break;
                 case RemoteScannerEventType.ExitFromMenu:
                     _logger.LogVerbose(Message.SyncRemoteScannerExitFromMenuEventRaise);
                     RemoteScannerExitFromMenu.RaiseEvent(this);
                     break;
             }
             Thread.Sleep(TimeSpan.FromSeconds(1));
         }
     }
     finally
     {
         Monitor.Exit(s_handleRemoteScannerEventSync);
     }
 }