Example #1
0
        public BackgroundCancelDialog(System.Threading.Thread thread, IExternalDrivenBackgroundMonitor monitor)
        {
            _thread  = thread;
            _monitor = monitor;
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            btCancel.Visible     = monitor != null;
            _btInterrupt.Visible = monitor == null;
            _btAbort.Visible     = false;
        }
Example #2
0
    public BackgroundCancelDialog(  System.Threading.Thread thread, IExternalDrivenBackgroundMonitor monitor)
    {
      _thread = thread;
      _monitor = monitor;
      //
      // Required for Windows Form Designer support
      //
      InitializeComponent();

      btCancel.Visible = monitor != null;
      _btInterrupt.Visible = monitor == null;
      _btAbort.Visible = false;

    }
Example #3
0
        public BackgroundCancelDialogWpf(System.Threading.Thread thread, IExternalDrivenBackgroundMonitor monitor)
        {
            _thread  = thread;
            _monitor = monitor;
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            _btCancel.Visibility    = monitor != null ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed;
            _btInterrupt.Visibility = monitor == null ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed;
            _btAbort.Visibility     = System.Windows.Visibility.Collapsed;
            _timerCounter           = 0;
        }
		public BackgroundCancelDialogWpf(System.Threading.Thread thread, IExternalDrivenBackgroundMonitor monitor)
		{
			_thread = thread;
			_monitor = monitor;
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			_btCancel.Visibility = monitor != null ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed;
			_btInterrupt.Visibility = monitor == null ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed;
			_btAbort.Visibility = System.Windows.Visibility.Collapsed;
			_timerCounter = 0;
		}
Example #5
0
        public BackgroundCancelDialog(System.Threading.ThreadStart threadstart, IExternalDrivenBackgroundMonitor monitor)
        {
            _monitor = monitor;

            _threadStart     = threadstart;
            _threadException = null;
            _thread          = new System.Threading.Thread(MonitoredThreadEntryPoint);
            _thread.Start();

            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            btCancel.Visible     = monitor != null;
            _btInterrupt.Visible = monitor == null;
            _btAbort.Visible     = false;
        }
		public BackgroundCancelDialogWpf(System.Threading.ThreadStart threadstart, IExternalDrivenBackgroundMonitor monitor)
		{
			_monitor = monitor;

			_threadStart = threadstart;
			_threadException = null;
			_thread = new System.Threading.Thread(MonitoredThreadEntryPoint);
			_thread.Start();

			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			_btCancel.Visibility = monitor != null ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed;
			_btInterrupt.Visibility = monitor == null ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed;
			_btAbort.Visibility = System.Windows.Visibility.Collapsed;
		}
Example #7
0
        public override bool ShowBackgroundCancelDialog(int millisecondsDelay, IExternalDrivenBackgroundMonitor monitor, System.Threading.Thread thread)
        {
            for (int i = 0; i < millisecondsDelay && thread.IsAlive; i += 10)
            {
                System.Threading.Thread.Sleep(10);
            }

            if (thread.IsAlive)
            {
                BackgroundCancelDialog dlg = new BackgroundCancelDialog(thread, monitor);

                if (thread.IsAlive)
                {
                    System.Windows.Forms.DialogResult r = dlg.ShowDialog(MainWindow);
                    return(r == System.Windows.Forms.DialogResult.OK ? false : true);
                }
            }
            return(false);
        }
		public void StartExecution(Action<IProgressReporter> action, int milliSecondsUntilShowUp)
		{
			if (_thread != null && _thread.IsAlive)
				throw new ApplicationException("Background thread is still executed");

			if (null != _timer)
				throw new ApplicationException("Timer is still active");

			_monitor = new ExternalDrivenBackgroundMonitor();
			_thread = new System.Threading.Thread(() => action(_monitor));

			_btCancel.Visibility = _monitor != null ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed;
			_btInterrupt.Visibility = _monitor == null ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed;
			_btAbort.Visibility = System.Windows.Visibility.Collapsed;

			_showUpDownConter = milliSecondsUntilShowUp / TimerTick_ms;
			_thread.Start();

			_timer = new System.Windows.Threading.DispatcherTimer(new TimeSpan(0, 0, 0, 0, TimerTick_ms), System.Windows.Threading.DispatcherPriority.Normal, EhTimer, this.Dispatcher);
		}
Example #9
0
        public void StartExecution(Action <IProgressReporter> action, int milliSecondsUntilShowUp)
        {
            if (_thread != null && _thread.IsAlive)
            {
                throw new ApplicationException("Background thread is still executed");
            }

            if (null != _timer)
            {
                throw new ApplicationException("Timer is still active");
            }

            _monitor = new ExternalDrivenBackgroundMonitor();
            _thread  = new System.Threading.Thread(() => action(_monitor));

            _btCancel.Visibility    = _monitor != null ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed;
            _btInterrupt.Visibility = _monitor == null ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed;
            _btAbort.Visibility     = System.Windows.Visibility.Collapsed;

            _showUpDownConter = milliSecondsUntilShowUp / TimerTick_ms;
            _thread.Start();

            _timer = new System.Windows.Threading.DispatcherTimer(new TimeSpan(0, 0, 0, 0, TimerTick_ms), System.Windows.Threading.DispatcherPriority.Normal, EhTimer, Dispatcher);
        }
Example #10
0
        public override bool ShowBackgroundCancelDialog(int millisecondsDelay, Thread thread, IExternalDrivenBackgroundMonitor monitor)
        {
            if (Current.Dispatcher.InvokeRequired)
            {
                throw new ApplicationException("Trying to show a BackgroundCancelDialog initiated by a background thread. This nesting is not supported");
            }

            for (int i = 0; i < millisecondsDelay && thread.IsAlive; i += 10)
            {
                System.Threading.Thread.Sleep(10);
            }

            if (thread.IsAlive)
            {
                var dlg = new BackgroundCancelDialogWpf(thread, monitor);
                if (thread.IsAlive)
                {
                    dlg.Owner = MainWindowWpf;
                    return(true == InternalShowModalWindow(dlg));
                }
            }
            return(false);
        }
Example #11
0
		public override bool ShowBackgroundCancelDialog(int millisecondsDelay, IExternalDrivenBackgroundMonitor monitor, System.Threading.Thread thread)
		{
			if (InvokeRequired())
				throw new ApplicationException("Trying to show a BackgroundCancelDialog initiated by a background thread. This nesting is not supported");

			for (int i = 0; i < millisecondsDelay && thread.IsAlive; i += 10)
				System.Threading.Thread.Sleep(10);

			if (thread.IsAlive)
			{
				var dlg = new BackgroundCancelDialogWpf(thread, monitor);
				if (thread.IsAlive)
				{
					dlg.Owner = MainWindowWpf;
					return true == InternalShowModalWindow(dlg);
				}
			}
			return false;
		}
    public override bool ShowBackgroundCancelDialog(int millisecondsDelay, IExternalDrivenBackgroundMonitor monitor, System.Threading.Thread thread)
    {
      for (int i = 0; i < millisecondsDelay && thread.IsAlive; i += 10)
        System.Threading.Thread.Sleep(10);

      if (thread.IsAlive)
      {
        BackgroundCancelDialog dlg = new BackgroundCancelDialog(thread, monitor);

        if (thread.IsAlive)
        {
          System.Windows.Forms.DialogResult r = dlg.ShowDialog(MainWindow);
          return r == System.Windows.Forms.DialogResult.OK ? false : true;
        }
      }
      return false;
    }
 public bool ShowBackgroundCancelDialog(int millisecondsDelay, System.Threading.ThreadStart threadstart, IExternalDrivenBackgroundMonitor monitor)
 {
   System.Threading.Thread t = new System.Threading.Thread(threadstart);
   t.Start();
   return ShowBackgroundCancelDialog(millisecondsDelay, t, monitor);
 }
Example #14
0
 public bool ShowBackgroundCancelDialog(int millisecondsDelay, System.Threading.ThreadStart threadstart, IExternalDrivenBackgroundMonitor monitor)
 {
     System.Threading.Thread t = new System.Threading.Thread(threadstart);
     t.Start();
     return(ShowBackgroundCancelDialog(millisecondsDelay, t, monitor));
 }
Example #15
0
 public abstract bool ShowBackgroundCancelDialog(int millisecondsDelay, Thread thread, IExternalDrivenBackgroundMonitor monitor);