Ejemplo n.º 1
0
        protected bool WaitAny(
            WaitHandle[] events, out int occurredEventIndex, int timeout, IWaitController waitCtrl)
        {
            var eventsEx          = new WaitHandle[events.Length + 1];
            var disposeEventIndex = events.Length;

            events.CopyTo(eventsEx, 0);
            eventsEx[disposeEventIndex] = _disposeEvent;
            occurredEventIndex          =
                waitCtrl == null
                    ? WaitHandle.WaitAny(eventsEx, timeout)
                    : waitCtrl.WaitAny(eventsEx, timeout);

            return(occurredEventIndex != disposeEventIndex);
        }
Ejemplo n.º 2
0
        private int SetIndicatorAndPlayPhrase(
            IWaitController waitController,
            WaitHandle[] waitedEventsDuringPlaying,
            EventWaitHandle playSoundFinishedEvent,
            string text, string[] sounds, bool silent)
        {
            if (!string.IsNullOrEmpty(text))
            {
                _logger.LogInfo(Message.WorkflowText, text);
                _scannerManager.SetIndicator(text);
            }
            var occurredEventIndex = -1;

            if (!silent)
            {
                ResetEvents(waitedEventsDuringPlaying);
                _soundManager.PlaySounds(sounds, (sender, e) => playSoundFinishedEvent.Set());
                try
                {
                    occurredEventIndex = waitController.WaitAny(waitedEventsDuringPlaying);
                    if (occurredEventIndex <= waitedEventsDuringPlaying.Length - 2)
                    {
                        _soundManager.StopPlaying();
                        return(occurredEventIndex);
                    }
                    occurredEventIndex = -1;
                }
                catch (ActivityExecutionInterruptException)
                {
                    _soundManager.StopPlaying();
                    _logger.LogVerbose(Message.WorkflowSoundPlayingStoppedByActivityExecutionInterrupt);
                    throw;
                }
            }
            return(occurredEventIndex);
        }
Ejemplo n.º 3
0
 protected bool WaitAny( 
     WaitHandle[] events, out int occurredEventIndex, int timeout, IWaitController waitCtrl)
 {
     var eventsEx = new WaitHandle[events.Length + 1];
     var disposeEventIndex = events.Length;
     events.CopyTo(eventsEx, 0);
     eventsEx[disposeEventIndex] = _disposeEvent;
     occurredEventIndex =
         waitCtrl == null
             ? WaitHandle.WaitAny(eventsEx, timeout)
             : waitCtrl.WaitAny(eventsEx, timeout);
     return occurredEventIndex != disposeEventIndex;
 }
Ejemplo n.º 4
0
 private int SetIndicatorAndPlayPhrase( 
     IWaitController waitController, 
     WaitHandle[] waitedEventsDuringPlaying, 
     EventWaitHandle playSoundFinishedEvent, 
     string text, string[] sounds, bool silent)
 {
     if (!string.IsNullOrEmpty(text))
     {
         _logger.LogInfo(Message.WorkflowText, text);
         _scannerManager.SetIndicator(text);
     }
     var occurredEventIndex = -1;
     if (!silent)
     {
         ResetEvents(waitedEventsDuringPlaying);
         _soundManager.PlaySounds(sounds, (sender, e) => playSoundFinishedEvent.Set());
         try
         {
             occurredEventIndex = waitController.WaitAny(waitedEventsDuringPlaying);
             if (occurredEventIndex <= waitedEventsDuringPlaying.Length - 2)
             {
                 _soundManager.StopPlaying();
                 return occurredEventIndex;
             }
             occurredEventIndex = -1;
         }
         catch (ActivityExecutionInterruptException)
         {
             _soundManager.StopPlaying();
             _logger.LogVerbose(Message.WorkflowSoundPlayingStoppedByActivityExecutionInterrupt);
             throw;
         }
     }
     return occurredEventIndex;
 }