Пример #1
0
 private void RaiseStateChange(TestTickSourceState state, int count, int total)
 {
     if (OnStateChange != null)
     {
         if (_syncContext != null)
         {
             _syncContext.RunAsync(() => { OnStateChange(state, count, total); });
         }
         else
         {
             OnStateChange(state, count, total);
         }
     }
 }
Пример #2
0
        private void _tickSource_OnStateChange(TestTickSourceState state, int countTicks, int totalTicks)
        {
            if (_progress == null)
            {
                return;
            }

            double percent;

            if (totalTicks != 0)
            {
                percent = (double)countTicks / totalTicks * 100;
            }
            else
            {
                percent = 100;
            }

            if (state == TestTickSourceState.Running)
            {
                _progress.OnProgress(percent);
            }
            else if (state == TestTickSourceState.Completed)
            {
                Complete();
                _progress.OnProgress(percent);
                _progress.OnComplete();
                _finished?.Invoke(true);
            }
            else if (state == TestTickSourceState.Stopped)
            {
                _progress.OnProgress(percent);
                _progress.OnAbort();
                _finished?.Invoke(false);
            }
        }