Пример #1
0
        private void RefreshCapturingState()
        {
            var isRunning       = _cancellationTokenSource != null && RunState == RunStateEnum.Running;
            var shouldBeRunning = UserSettings.TransferActive ||
                                  SettingsViewModel.IsSettingsWindowOpen && SettingsViewModel.IsPreviewTabOpen;

            if (isRunning && !shouldBeRunning)
            {
                // Stop it!
                _log.Debug("stopping the capturing");
                RunState = RunStateEnum.Stopping;
                _cancellationTokenSource.Cancel();
                _cancellationTokenSource = null;
            }
            else if (!isRunning && shouldBeRunning)
            {
                // Start it
                _log.Debug("starting the capturing");
                _cancellationTokenSource = new CancellationTokenSource();
                var thread = new Thread(() => Run(_cancellationTokenSource.Token))
                {
                    IsBackground = true,
                    Priority     = ThreadPriority.BelowNormal,
                    Name         = "DesktopDuplicatorReader"
                };
                thread.Start();
            }
        }
 public BaseProperties(string dId, string dName, string dFullname, int dTestcasecount, RunStateEnum dRunstate)
 {
     Id            = dId;
     Name          = dName;
     Fullname      = dFullname;
     TestCaseCount = dTestcasecount;
     RunState      = dRunstate;
 }
Пример #3
0
 public void Run(CancellationToken token)
 {
     Task.Factory.StartNew(() =>
     {
         RunState = RunStateEnum.Running;
         try
         {
             token.WaitHandle.WaitOne();
         }
         finally
         {
             RunState = RunStateEnum.Stopped;
         }
     });
 }