Ejemplo n.º 1
0
 private void OnStatusChanged(object sender, StatusChangedManuallyEventArgs eventArgs)
 {
     Notification.Send(eventArgs.Status);
     if (SyncCheckbox.IsChecked.HasValue && SyncCheckbox.IsChecked.Value && eventArgs.Manually)
     {
         CommunicatorService.SetStatus(eventArgs.Status);
     }
 }
Ejemplo n.º 2
0
        private void WorkerOnDoWork(object sender, DoWorkEventArgs doWorkEventArgs)
        {
            do
            {
                (sender as BackgroundWorker).ReportProgress(0, CommunicatorService.GetCurrentStatus());
                Thread.Sleep(5000);
            } while (myWorker != null && !myWorker.CancellationPending);

            if (myWorker == null)
            {
                return;
            }
            myWorker.ProgressChanged -= WorkerOnProgressChanged;
            myWorker.DoWork          -= WorkerOnDoWork;
            myWorker.Dispose();
            myWorker = null;
        }
Ejemplo n.º 3
0
        private void CheckBox_Checked(object sender, RoutedEventArgs e)
        {
            if (!CommunicatorService.IsRunning())
            {
                ((CheckBox)sender).IsChecked = false;
                return;
            }

            myWorker = new BackgroundWorker
            {
                WorkerReportsProgress      = true,
                WorkerSupportsCancellation = true
            };
            myWorker.ProgressChanged += WorkerOnProgressChanged;
            myWorker.DoWork          += WorkerOnDoWork;
            myWorker.RunWorkerAsync();
        }