System.Windows.Threading.DispatcherTimer.Stop()

Here are the examples of the csharp api System.Windows.Threading.DispatcherTimer.Stop() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

560 Examples 7

19 View Source File : GalleryView.xaml.cs
License : MIT License
Project Creator : AlexanderPro

public void Pause()
        {
            _timerForShow.Stop();
            _timerForHide.Stop();
            State = GalleryState.Pause;
            ((BaseViewModel)DataContext).Settings.GalleryState = State;
        }

19 View Source File : Session.cs
License : GNU General Public License v3.0
Project Creator : Amebis

public void Run()
        {
            try
            {
                Parallel.ForEach(PreRun,
                    action =>
                    {
                        Wizard.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() => Wizard.TaskCount++));
                        try { action(); }
                        finally { Wizard.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() => Wizard.TaskCount--)); }
                    });
            }
            catch (AggregateException ex)
            {
                var nonCancelledException = ex.InnerExceptions.Where(exInner => !(exInner is OperationCanceledException));
                if (nonCancelledException.Any())
                    throw new AggregateException("", nonCancelledException.ToArray());
                throw new OperationCanceledException();
            }

            DoRun();
            ConnectedTimeUpdater.Stop();
        }

19 View Source File : MainControl.xaml.cs
License : MIT License
Project Creator : Actipro

public override void NotifyUnloaded() {
			this.timer.Stop();
		}

19 View Source File : VirtualControl.cs
License : MIT License
Project Creator : alaabenfatma

public void GoForNode(Node node)
        {
            node.X = Math.Truncate(node.X);
            node.Y = Math.Truncate(node.Y);
            var origin = BasisOrigin;
            origin.X -= node.ActualWidth - 10;
            origin.X = Math.Truncate(origin.X);
            origin.Y = Math.Truncate(origin.Y);
            var difference = Point.Subtract(origin, new Point(node.X, node.Y));
            var timer = new DispatcherTimer {Interval = new TimeSpan(0, 0, 0, 0, 01)};
            foreach (var n in Nodes)
            {
                if (difference.X < 0)
                    n.X += difference.X;
                else
                    n.X += difference.X;
                if (difference.Y < 0)
                    n.Y += difference.Y;
                else
                    n.Y += difference.Y;
                NeedsRefresh = true;
            }
            difference.X = 10;
            difference.Y = 0;
            if (difference.X != 0 || difference.Y != 0)
                timer.Start();
            timer.Tick += (s, e) =>
            {
                if (difference.X == 0 && difference.Y == 0)
                    timer.Stop();
                foreach (var n in Nodes)
                {
                    if (difference.X > 0)
                        n.X++;
                    else
                        n.X--;
                    if (difference.Y > 0)
                        n.Y++;
                    else
                        n.Y--;
                }
                if (difference.X > 0)
                    difference.X--;
                else
                    difference.X++;
                if (difference.Y > 0)
                    difference.Y--;
                else
                    difference.Y++;
            };
            SelectedNodes.Clear();
            SelectedNodes.Add(node);
        }

19 View Source File : WindowInBandWrapper.cs
License : MIT License
Project Creator : ADeltaX

private void Window_PreviewStylusUp(object sender, StylusEventArgs e)
        {
            _elapsedTimer.Stop();
            _elapsedTimer.Start();
        }

19 View Source File : MainControl.xaml.cs
License : MIT License
Project Creator : Actipro

private void OnFileCopyTimerTick(object sender, EventArgs e) {
			if ((null != this.fileCopyTimer) && (0 == this.FileCopyData.RemainingFileCount)) {
				this.fileCopyTimer.Stop();
				this.fileCopyTimer.Tick -= new EventHandler(OnFileCopyTimerTick);
				this.fileCopyTimer = null;
			}
			else {
				SimulateFileCopy();
			}
		}

19 View Source File : WebView.xaml.cs
License : MIT License
Project Creator : AlexanderPro

public void Refresh()
        {
            _timer?.Stop();
            _timer?.Start();
            Browser.GetBrowser().Reload(true);
        }

19 View Source File : HeatMapExampleView.xaml.cs
License : MIT License
Project Creator : ABTSoftware

private void OnExampleUnloaded(object sender, RoutedEventArgs e)
        {
            _timer.Stop();
        }

19 View Source File : PluginMainWorker.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : anoyetta

public void End()
        {
            this.isOver = true;

            // Workerを開放する
            this.refreshSpellOverlaysWorker?.Stop();
            this.refreshTickerOverlaysWorker?.Stop();
            this.detectLogsWorker?.Abort();
            this.syncHotbarWorker?.Abort();

            this.refreshSpellOverlaysWorker = null;
            this.refreshTickerOverlaysWorker = null;
            this.detectLogsWorker = null;
            this.syncHotbarWorker = null;

            this.backgroudWorker?.Stop();
            this.backgroudWorker?.Dispose();
            this.backgroudWorker = null;

            // ログバッファを開放する
            if (this.LogBuffer != null)
            {
                this.LogBuffer.Dispose();
                this.LogBuffer = null;
            }

            // Windowを閉じる
            SpellsController.Instance.ClosePanels();
            TickersController.Instance.CloseTelops();
            SpellsController.Instance.ExecuteClosePanels();
            TickersController.Instance.ExecuteCloseTelops();

            // 設定を保存する
            Settings.Default.Save();
            SpellPanelTable.Instance.Save();
            SpellTable.Instance.Save();
            TickerTable.Instance.Save();
            TagTable.Instance.Save();

            // サウンドコントローラを停止する
            SoundController.Instance.End();

            // テーブルコンパイラを停止する
            TableCompiler.Instance.End();
            TableCompiler.Free();

            // FFXIVのスキャンを停止する
            XIVPluginHelper.Instance.End();
            XIVPluginHelper.Free();
        }

19 View Source File : DispatcherScheduler.cs
License : MIT License
Project Creator : ABTSoftware

public IDisposable SchedulePeriodic<TState>(
          TState state,
          TimeSpan period,
          Func<TState, TState> action)
        {
            if (period < TimeSpan.Zero)
                throw new ArgumentOutOfRangeException(nameof(period));
            if (action == null)
                throw new ArgumentNullException(nameof(action));
            DispatcherTimer timer = new DispatcherTimer(this._priority, this._dispatcher);
            TState state1 = state;
            timer.Tick += (EventHandler)((s, e) => state1 = action(state1));
            timer.Interval = period;
            timer.Start();
            return Disposable.Create((Action)(() =>
            {
                DispatcherTimer dispatcherTimer = Interlocked.Exchange<DispatcherTimer>(ref timer, (DispatcherTimer)null);
                if (dispatcherTimer == null)
                    return;
                dispatcherTimer.Stop();
                action = (Func<TState, TState>)(_ => _);
            }));
        }

19 View Source File : Spinner.xaml.cs
License : MIT License
Project Creator : AkiniKites

private void OnCanvasUnloaded(object sender, RoutedEventArgs e)
        {
            _timer.Stop();
            _timer.Tick -= OnTimerTick;
        }

19 View Source File : WindowInBandWrapper.cs
License : MIT License
Project Creator : ADeltaX

private void Window_PreviewStylusDown(object sender, StylusDownEventArgs e) => _elapsedTimer.Stop();

19 View Source File : DispatcherTimerRunner.cs
License : MIT License
Project Creator : ABTSoftware

public override void Run()
        {
            // NOTE: Uncomment this line to execute the Test Timer on a background thread. It makes a big difference to test performance
            // Why? Because Append is slow. Also DispatcherTimer is on the UI. It cannot run while the render takes place. 
            // I will profile the app with DispatcherTimer to see if there are any improvements. 
            // Meanwhile, you test with Threading.Timer as it will give you more accurate results
            
            //base.Run(); return;

            var timer = new DispatcherTimer();
            //timer.Interval = TimeSpan.FromMilliseconds(10); // 100Hz
            timer.Interval = TimeSpan.FromMilliseconds(0); //Arction 
            EventHandler tickHandler = null;
            tickHandler = (s, e) =>
                {
                    _testCallback();

                    if (_stopWatch.ElapsedMilliseconds > _duration.TotalMilliseconds)
                    {
                        _stopWatch.Stop();
                        timer.Tick -= tickHandler;
                        timer.Stop();
                        double fps = _frameCount / _stopWatch.Elapsed.TotalSeconds;
                        _completedCallback(fps);
                    }
                };

            timer.Tick += tickHandler;
            _stopWatch = Stopwatch.StartNew();
            timer.Start();
        }

19 View Source File : GalleryView.xaml.cs
License : MIT License
Project Creator : AlexanderPro

private void TimerForShowTick(object sender, EventArgs e)
        {
            _timerForShow.Stop();
            Image.ChangeSource(new BitmapImage(new Uri(CurrentFile)), TimeSpan.FromMilliseconds(500), TimeSpan.FromMilliseconds(500));
            _timerForHide.Start();
        }

19 View Source File : RealTimePolarChartExampleView.xaml.cs
License : MIT License
Project Creator : ABTSoftware

private void OnExampleUnloaded(object sender, RoutedEventArgs e)
        {
            if (_timer != null)
            {
                _timer.Stop();

                _timer.Tick -= TimerOnElapsed;

                _timer = null;
            }
        }

19 View Source File : SystemInformationView.xaml.cs
License : MIT License
Project Creator : AlexanderPro

private void UserControl_Unloaded(object sender, System.Windows.RoutedEventArgs e)
        {
            _timer?.Stop();
            _timer = null;
        }

19 View Source File : Stock.cs
License : MIT License
Project Creator : Actipro

public void StopUpdatingPriceData() {
			timer.Stop();
		}

19 View Source File : DispatcherOnScreenKeyboardWatcher.cs
License : MIT License
Project Creator : AlexeiScherbakov

protected override void Dispose(bool disposing)
		{
			_timer.Stop();
			base.Dispose(disposing);
		}

19 View Source File : CreateRealTime3DPointCloudChart.xaml.cs
License : MIT License
Project Creator : ABTSoftware

private void OnReset()
        {
            _timer.Stop();

            StartButton.IsChecked = false;
            PauseButton.IsChecked = false;
            ResetButton.IsChecked = true;

            using (sciChart.SuspendUpdates())
            {
                ScatterRenderableSeries3D.DataSeries = null;
                sciChart.InvalidateElement();

                ScatterRenderableSeries3D.GetSceneEnreplacedy().Update();
                ScatterRenderableSeries3D.GetSceneEnreplacedy().RootSceneEnreplacedy.Update();
            }
        }

19 View Source File : LPSView.xaml.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : anoyetta

private void LPSView_Closed(object sender, EventArgs e)
        {
            this.timer.Stop();
            this.timer = null;
        }

19 View Source File : WindowInBandWrapper.cs
License : MIT License
Project Creator : ADeltaX

private void SetupHideTimer()
        {
#if DEBUG
            _elapsedTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(20) };
#else
            _elapsedTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(2.5) };
#endif

            _elapsedTimer.Tick += (_, __) =>
            {
                _elapsedTimer.Stop();
                Hide();
            };
        }

19 View Source File : WindowInBandWrapper.cs
License : MIT License
Project Creator : ADeltaX

private void Window_PreviewMouseUp(object sender, MouseButtonEventArgs e)
        {
            _elapsedTimer.Stop();
            _elapsedTimer.Start();
        }

19 View Source File : CreateRealTime3DPointCloudChart.xaml.cs
License : MIT License
Project Creator : ABTSoftware

private void CreateRealTime3DPointCloudChart_OnUnloaded(object sender, RoutedEventArgs e)
        {
            if (_timer != null)
            {
                _timer.Stop();
                _timer.Tick -= OnTimerTick;
                _timer = null;
            }
        }

19 View Source File : WindowInBandWrapper.cs
License : MIT License
Project Creator : ADeltaX

private void Window_PreviewMouseDown(object sender, MouseButtonEventArgs e) => _elapsedTimer.Stop();

19 View Source File : DispatcherScheduler.cs
License : MIT License
Project Creator : ABTSoftware

public override IDisposable Schedule<TState>(
          TState state,
          TimeSpan dueTime,
          Func<IScheduler, TState, IDisposable> action)
        {
            if (action == null)
                throw new ArgumentNullException(nameof(action));
            TimeSpan timeSpan = Scheduler.Normalize(dueTime);
            if (timeSpan.Ticks == 0L)
                return this.Schedule<TState>(state, action);
            MultiplereplacedignmentDisposable d = new MultiplereplacedignmentDisposable();
            DispatcherTimer timer = new DispatcherTimer(this._priority, this._dispatcher);
            timer.Tick += (EventHandler)((s, e) =>
            {
                DispatcherTimer dispatcherTimer = Interlocked.Exchange<DispatcherTimer>(ref timer, (DispatcherTimer)null);
                if (dispatcherTimer == null)
                    return;
                try
                {
                    d.Disposable = action((IScheduler)this, state);
                }
                finally
                {
                    dispatcherTimer.Stop();
                    action = (Func<IScheduler, TState, IDisposable>)null;
                }
            });
            timer.Interval = timeSpan;
            timer.Start();
            d.Disposable = Disposable.Create((Action)(() =>
            {
                DispatcherTimer dispatcherTimer = Interlocked.Exchange<DispatcherTimer>(ref timer, (DispatcherTimer)null);
                if (dispatcherTimer == null)
                    return;
                dispatcherTimer.Stop();
                action = (Func<IScheduler, TState, IDisposable>)((_, __) => Disposable.Empty);
            }));
            return (IDisposable)d;
        }

19 View Source File : Spinner.xaml.cs
License : MIT License
Project Creator : AkiniKites

private void OnVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if ((bool)e.NewValue)
            {
                _timer.Tick += OnTimerTick;
                _timer.Start();
            }
            else
            {
                _timer.Stop();
                _timer.Tick -= OnTimerTick;
            }
        }

19 View Source File : WindowInBandWrapper.cs
License : MIT License
Project Creator : ADeltaX

public void Show()
        {
            ShowWindowAsync(_inBandWindowHandle, (int)ShowWindowCommands.Show);
            _elapsedTimer.Stop();
            _elapsedTimer.Start();
            _isVisible = true;
        }

19 View Source File : LoadingContent.xaml.cs
License : MIT License
Project Creator : ABTSoftware

public void StopTimer()
        {
            initStopwatch.Stop();
            timer.Stop();
            timerTextBlock.Text = initStopwatch.Elapsed.ToString("ss\\.fff");
        }

19 View Source File : Notification.cs
License : MIT License
Project Creator : alaabenfatma

public void Show(string msg)
        {
            Loaded += (s, e) =>
            {
                var b = Template.FindName("b", this) as Border;
                var m = Template.FindName("Message", this) as TextBlock;
                m.Text = msg;
                b.SizeChanged += (ss, ee) =>
                {
                    Width = b.ActualWidth;
                    Height = b.ActualHeight;
                };

                VerticalContentAlignment = VerticalAlignment.Bottom;
                HorizontalAlignment = HorizontalAlignment.Right;

                Visibility = Visibility.Visible;
                var timer = new DispatcherTimer {Interval = new TimeSpan(0, 0, 3), IsEnabled = true};
                timer.Tick += (ts, te) =>
                {
                    host.Children.Remove(this);
                    timer.Stop();
                };
                host.Children.Add(this);
            };
        }

19 View Source File : RealTimeStaticAxis.xaml.cs
License : MIT License
Project Creator : ABTSoftware

private void OnExampleUnloaded(object sender, RoutedEventArgs e)
        {
            if (_timer != null)
            {
                _timer.Stop();
                _timer.Tick -= TimerOnElapsed;
                _timer = null;
            }
        }

19 View Source File : VariablesList.cs
License : MIT License
Project Creator : alaabenfatma

private void VariableHoster_PreviewMouseUp(object sender, MouseButtonEventArgs e)
        {
            _positioner.Stop();
            PlantTheVariable();
            Close();
            e.Handled = true;
        }

19 View Source File : MainControl.xaml.cs
License : MIT License
Project Creator : Actipro

private void OnCancelButtonClick(object sender, RoutedEventArgs e) {
			if (null != this.fileCopyTimer) {
				this.fileCopyTimer.Stop();
				this.fileCopyTimer.Tick -= new EventHandler(OnFileCopyTimerTick);
				this.fileCopyTimer = null;
			}
		}

19 View Source File : GalleryView.xaml.cs
License : MIT License
Project Creator : AlexanderPro

private void TimerForHideTick(object sender, EventArgs e)
        {
            _timerForHide.Stop();
            Image.ChangeSource(new BitmapImage(new Uri("pack://application:,,,/Images/1x1.png")), TimeSpan.FromMilliseconds(500), TimeSpan.FromMilliseconds(500));
            _timerForShow.Start();
        }

19 View Source File : CreateRealTime3DPointCloudChart.xaml.cs
License : MIT License
Project Creator : ABTSoftware

private void OnPause()
        {
            _timer.Stop();

            StartButton.IsChecked = false;
            PauseButton.IsChecked = true;
            ResetButton.IsChecked = false;
        }

19 View Source File : GalleryView.xaml.cs
License : MIT License
Project Creator : AlexanderPro

public void Stop()
        {
            _timerForShow.Stop();
            _timerForHide.Stop();

            State = GalleryState.Stop;
            var viewModel = (BaseViewModel)DataContext;
            viewModel.Settings.GalleryState = State;
            _currentFileIndex = -1;
            if (Directory.Exists(viewModel.Settings.GalleryDirectoryName))
            {
                var directoryInfo = new DirectoryInfo(viewModel.Settings.GalleryDirectoryName);
                _files = directoryInfo.GetFilesByExtensions(viewModel.Settings.GalleryFileExtensions.Select(x => x.Replace("*", "")).ToArray()).Select(x => x.FullName).ToList();
            }
        }

19 View Source File : MainControl.xaml.cs
License : MIT License
Project Creator : Actipro

private void ToggleTimerRunning() {
			if (timer == null) {
				timer = new DispatcherTimer();
				timer.Tick += OnTimerTick;
				timer.Interval = TimeSpan.FromMilliseconds(100);
			}

			if (timer.IsEnabled) {
				startStopButton.Content = "\uE102";
				timer.Stop();
			}
			else {
				minutesSlider.Value = minutesSlice.EndAngle;
				secondsSlider.Value = secondsSlice.EndAngle;
				startTime = DateTimeOffset.Now;

				startStopButton.Content = "\uE103";
				timer.Start();
			}

			minutesSlider.Opacity = (timer.IsEnabled ? 0.0 : 1.0);
			secondsSlider.Opacity = (timer.IsEnabled ? 0.0 : 1.0);
		}

19 View Source File : SystemInformationView.xaml.cs
License : MIT License
Project Creator : AlexanderPro

public void Refresh()
        {
            _timer?.Stop();
            _timer?.Start();
            (DataContext as BaseViewModel)?.Refresh();
        }

19 View Source File : TilesHarmonistBehavior.cs
License : MIT License
Project Creator : ABTSoftware

private void OnUnloaded(object sender, RoutedEventArgs routedEventArgs)
        {
            if (_timer != null)
            {
                _timer.Stop();
                _timer = null;
            }
        }

19 View Source File : VideoView.xaml.cs
License : MIT License
Project Creator : AlexanderPro

private void UserControl_Unloaded(object sender, RoutedEventArgs e)
        {
            _timer?.Stop();
            _timer = null;
            mediaPlayer?.Stop();
            mediaPlayer?.Close();
            mediaPlayer = null;
        }

19 View Source File : MainControl.xaml.cs
License : MIT License
Project Creator : Actipro

public override void NotifyUnloaded() {
			timer.Stop();
		}

19 View Source File : OpenVPNSession.cs
License : GNU General Public License v3.0
Project Creator : Amebis

protected override void DoRun()
        {
            Wizard.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() => Wizard.TaskCount++));
            try
            {
                try
                {
                    // Start OpenVPN management interface on IPv4 loopack interface (any TCP free port).
                    var mgmtServer = new TcpListener(IPAddress.Loopback, 0);
                    mgmtServer.Start();
                    try
                    {
                        try
                        {
                            // Purge stale log files.
                            var timestamp = DateTime.UtcNow.Subtract(new TimeSpan(30, 0, 0, 0));
                            foreach (var f in Directory.EnumerateFiles(WorkingFolder, "*.txt", SearchOption.TopDirectoryOnly))
                            {
                                SessionAndWindowInProgress.Token.ThrowIfCancellationRequested();
                                if (File.GetLastWriteTimeUtc(f) <= timestamp)
                                {
                                    try { File.Delete(LogPath); }
                                    catch { }
                                }
                            }
                        }
                        catch (OperationCanceledException) { throw; }
                        catch (Exception) { /* Failure to remove stale log files is not fatal. */ }

                        try
                        {
                            // Save OpenVPN configuration file.
                            using (var fs = new FileStream(
                                ConfigurationPath,
                                FileMode.Create,
                                FileAccess.Write,
                                FileShare.Read,
                                1048576,
                                FileOptions.SequentialScan))
                            using (var sw = new StreamWriter(fs))
                            {
                                // Save profile's configuration to file.

                                if (Properties.SettingsEx.Default.OpenVPNRemoveOptions is StringCollection openVPNRemoveOptions)
                                {
                                    // Remove options on the OpenVPNRemoveOptions list on the fly.
                                    using (var sr = new StringReader(ProfileConfig))
                                    {
                                        string inlineTerm = null;
                                        bool inlineRemove = false;
                                        for (; ; )
                                        {
                                            var line = sr.ReadLine();
                                            if (line == null)
                                                break;

                                            var trimmedLine = line.Trim();
                                            if (!string.IsNullOrEmpty(trimmedLine))
                                            {
                                                // Not an empty line.
                                                if (inlineTerm == null)
                                                {
                                                    // Not inside an inline option block = Regular parsing mode.
                                                    if (!trimmedLine.StartsWith("#") &&
                                                        !trimmedLine.StartsWith(";"))
                                                    {
                                                        // Not a comment.
                                                        var option = eduOpenVPN.Configuration.ParseParams(trimmedLine);
                                                        if (option.Count > 0)
                                                        {
                                                            if (option[0].StartsWith("<") && !option[0].StartsWith("</") && option[0].EndsWith(">"))
                                                            {
                                                                // Start of an inline option.
                                                                var o = option[0].Substring(1, option[0].Length - 2);
                                                                inlineTerm = "</" + o + ">";
                                                                inlineRemove = openVPNRemoveOptions.Contains(o);
                                                                if (inlineRemove)
                                                                {
                                                                    sw.WriteLine("# Commented by OpenVPNRemoveOptions setting:");
                                                                    line = "# " + line;
                                                                }
                                                            }
                                                            else if (openVPNRemoveOptions.Contains(option[0]))
                                                            {
                                                                sw.WriteLine("# Commented by OpenVPNRemoveOptions setting:");
                                                                line = "# " + line;
                                                            }
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    // Inside an inline option block.
                                                    if (inlineRemove)
                                                    {
                                                        // Remove the inline option content.
                                                        line = "# " + line;
                                                    }

                                                    if (trimmedLine == inlineTerm)
                                                    {
                                                        // Inline option terminator found. Returning to regular parsing mode.
                                                        inlineTerm = null;
                                                    }
                                                }
                                            }

                                            sw.WriteLine(line);
                                        }
                                    }
                                }
                                else
                                    sw.Write(ProfileConfig);

                                // Append eduVPN Client specific configuration directives.
                                sw.WriteLine();
                                sw.WriteLine();
                                sw.WriteLine("# eduVPN Client for Windows");

                                // Introduce ourself (to OpenVPN server).
                                var replacedembly = replacedembly.GetExecutingreplacedembly();
                                var replacedemblyreplacedleAttribute = Attribute.GetCustomAttributes(replacedembly, typeof(replacedemblyreplacedleAttribute)).SingleOrDefault() as replacedemblyreplacedleAttribute;
                                var replacedemblyVersion = replacedembly?.GetName()?.Version;
                                sw.WriteLine("setenv IV_GUI_VER " + eduOpenVPN.Configuration.EscapeParamValue(replacedemblyreplacedleAttribute?.replacedle + " " + replacedemblyVersion?.ToString()));

                                // Configure log file (relative to WorkingFolder).
                                sw.WriteLine("log-append " + eduOpenVPN.Configuration.EscapeParamValue(ConnectionId + ".txt"));

                                // Configure interaction between us and openvpn.exe.
                                sw.WriteLine("management " + eduOpenVPN.Configuration.EscapeParamValue(((IPEndPoint)mgmtServer.LocalEndpoint).Address.ToString()) + " " + eduOpenVPN.Configuration.EscapeParamValue(((IPEndPoint)mgmtServer.LocalEndpoint).Port.ToString()) + " stdin");
                                sw.WriteLine("management-client");
                                sw.WriteLine("management-hold");
                                sw.WriteLine("management-query-preplacedwords");
                                sw.WriteLine("management-query-remote");

                                // Configure client certificate.
                                sw.WriteLine("cert " + eduOpenVPN.Configuration.EscapeParamValue(ConnectingProfile.Server.ClientCertificatePath));
                                sw.WriteLine("key " + eduOpenVPN.Configuration.EscapeParamValue(ConnectingProfile.Server.ClientCertificatePath));

                                // Ask when username/preplacedword is denied.
                                sw.WriteLine("auth-retry interact");
                                sw.WriteLine("auth-nocache");

                                // Set Wintun interface to be used.
                                sw.Write("windows-driver wintun\n");
                                sw.Write("dev-node " + eduOpenVPN.Configuration.EscapeParamValue(Properties.Settings.Default.Clientreplacedle) + "\n");

#if DEBUG
                                // Renegotiate data channel every 5 minutes in debug versions.
                                sw.WriteLine("reneg-sec 300");
#endif

                                if (Environment.OSVersion.Version < new Version(6, 2))
                                {
                                    // Windows 7 is using tiny 8kB send/receive socket buffers by default.
                                    // Increase to 64kB which is default from Windows 8 on.
                                    sw.WriteLine("sndbuf 65536");
                                    sw.WriteLine("rcvbuf 65536");
                                }

                                var openVPNAddOptions = Properties.SettingsEx.Default.OpenVPNAddOptions;
                                if (!string.IsNullOrWhiteSpace(openVPNAddOptions))
                                {
                                    sw.WriteLine();
                                    sw.WriteLine();
                                    sw.WriteLine("# Added by OpenVPNAddOptions setting:");
                                    sw.WriteLine(openVPNAddOptions);
                                }
                            }
                        }
                        catch (OperationCanceledException) { throw; }
                        catch (Exception ex) { throw new AggregateException(string.Format(Resources.Strings.ErrorSavingProfileConfiguration, ConfigurationPath), ex); }

                        bool retry;
                        do
                        {
                            retry = false;

                            // Connect to OpenVPN Interactive Service to launch the openvpn.exe.
                            using (var openvpnInteractiveServiceConnection = new eduOpenVPN.InteractiveService.Session())
                            {
                                var mgmtPreplacedword = Membership.GeneratePreplacedword(16, 6);
                                try
                                {
                                    openvpnInteractiveServiceConnection.Connect(
                                        string.Format("openvpn{0}\\service", InstanceName),
                                        WorkingFolder,
                                        new string[] { "--config", ConnectionId + ".conf", },
                                        mgmtPreplacedword + "\n",
                                        3000,
                                        SessionAndWindowInProgress.Token);
                                }
                                catch (OperationCanceledException) { throw; }
                                catch (Exception ex) { throw new AggregateException(Resources.Strings.ErrorInteractiveService, ex); }

                                try
                                {
                                    // Wait and accept the openvpn.exe on our management interface (--management-client parameter).
                                    var mgmtClientTask = mgmtServer.AcceptTcpClientAsync();
                                    try { mgmtClientTask.Wait(30000, SessionAndWindowInProgress.Token); }
                                    catch (AggregateException ex) { throw ex.InnerException; }
                                    var mgmtClient = mgmtClientTask.Result;
                                    try
                                    {
                                        // Start the management session.
                                        ManagementSession.Start(mgmtClient.GetStream(), mgmtPreplacedword, SessionAndWindowInProgress.Token);

                                        // Initialize session and release openvpn.exe to get started.
                                        ManagementSession.SetVersion(3, SessionAndWindowInProgress.Token);
                                        ManagementSession.ReplayAndEnableState(SessionAndWindowInProgress.Token);
                                        ManagementSession.ReplayAndEnableEcho(SessionAndWindowInProgress.Token);
                                        ManagementSession.SetByteCount(5, SessionAndWindowInProgress.Token);
                                        ManagementSession.ReleaseHold(SessionAndWindowInProgress.Token);

                                        Wizard.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() => Wizard.TaskCount--));
                                        try
                                        {
                                            // Wait for the session to end gracefully.
                                            ManagementSession.Monitor.Join();
                                            if (ManagementSession.Error != null && !(ManagementSession.Error is OperationCanceledException))
                                            {
                                                // Session reported an error. Retry.
                                                retry = true;
                                            }
                                        }
                                        finally { Wizard.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() => Wizard.TaskCount++)); }
                                    }
                                    finally { mgmtClient.Close(); }
                                }
                                finally
                                {
                                    Wizard.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(
                                        () =>
                                        {
                                            // Cleanup status properties.
                                            State = SessionStatusType.Disconnecting;
                                            StateDescription = Resources.Strings.OpenVPNStateTypeExiting;
                                            TunnelAddress = null;
                                            IPv6TunnelAddress = null;
                                            ConnectedAt = null;
                                            BytesIn = null;
                                            BytesOut = null;
                                        }));

                                    // Wait for openvpn.exe to finish. Maximum 30s.
                                    try { Process.GetProcessById(openvpnInteractiveServiceConnection.ProcessId)?.WaitForExit(30000); }
                                    catch (ArgumentException) { }
                                }
                            }
                        } while (retry);
                    }
                    finally
                    {
                        mgmtServer.Stop();
                    }
                }
                finally
                {
                    // Delete profile configuration file. If possible.
                    try { File.Delete(ConfigurationPath); }
                    catch { }
                }
            }
            finally
            {
                Wizard.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(
                    () =>
                    {
                        // Cleanup status properties.
                        State = SessionStatusType.Disconnected;
                        StateDescription = "";

                        Wizard.TaskCount--;
                    }));
                PropertyUpdater.Stop();
            }
        }

19 View Source File : RealtimeWaterfall3DChart.xaml.cs
License : MIT License
Project Creator : ABTSoftware

private void OnExampleUnloaded(object sender, RoutedEventArgs e)
        {
            if (_timerNewDataUpdate != null)
            {
                _timerNewDataUpdate.Stop();
                _timerNewDataUpdate = null;
            }
        }

19 View Source File : TimelineVisualNoticeModel.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : anoyetta

public static void ClearToHideEntry()
        {
            lock (ToHideEntryList)
            {
                ToHideEntryList.Clear();
            }

            ToHideTimer.Stop();
        }

19 View Source File : WindowInBandWrapper.cs
License : MIT License
Project Creator : ADeltaX

public void MouseEnter() => _elapsedTimer.Stop();

19 View Source File : HeatMapExampleView.xaml.cs
License : MIT License
Project Creator : ABTSoftware

private void StopButton_Click(object sender, RoutedEventArgs e)
        {
            _timer.Stop();

            StartButton.IsChecked = false;
            StopButton.IsChecked = true;
        }

19 View Source File : MainWindow.xaml.MachineStatus.cs
License : MIT License
Project Creator : 3RD-Dimension

private void Machine_StatusChanged()
		{
			ButtonStatus.Content = machine.Status;

			if (machine.Status == "Alarm")
				ButtonStatus.Foreground = Brushes.Red;
			else if (machine.Status == "Hold")
				ButtonStatus.Foreground = Brushes.Yellow;
			else if (machine.Status == "Run")
				ButtonStatus.Foreground = Brushes.Green;
			else
				ButtonStatus.Foreground = Brushes.Black;

			if (StopRuntimeOnIdle && machine.Status == "Idle")
			{
				FileRuntimeTimer.Stop();
				FileRuntimeTimer_Tick(null, null);
				FileRunTime += DateTime.Now - LastFileStart;
				StopRuntimeOnIdle = false;
			}
		}

19 View Source File : CreateRealTime3DGeoidChart.xaml.cs
License : MIT License
Project Creator : ABTSoftware

private void OnStop()
        {
            if (_timer != null)
            {
                _timer.Stop();
                StartButton.IsEnabled = true;
                PauseButton.IsEnabled = false;
            }
        }

19 View Source File : RealtimeOrthogonalHeatmap3DChart.xaml.cs
License : MIT License
Project Creator : ABTSoftware

private void OnUnloaded(object sender, RoutedEventArgs routedEventArgs)
        {
            _timerNewDataUpdate.Stop();
        }

19 View Source File : Scatter3DOnChartWalls.xaml.cs
License : MIT License
Project Creator : ABTSoftware

private void Scatter3DOnChartWalls_Unloaded(object sender, EventArgs e)
        {
            if (_timer != null)
            {
                _timer.Stop();
                _timer.Tick -= OnTimerTick;
                _timer = null;
            }
        }

19 View Source File : MainWindow.xaml.cs
License : GNU General Public License v2.0
Project Creator : adrifcastr

public async void carmdrm()
        {
            statuslbl.Content = "Converting File...";

            Extract("OSAC", AppDomain.CurrentDomain.BaseDirectory + "\\res", "res", "ffmpeg.exe");

            string ffdir = AppDomain.CurrentDomain.BaseDirectory + "\\res\\ffmpeg.exe";
            string arg = @"-y -activation_bytes ";
            string arg1 = @" -i ";
            string arg2 = @" -ab ";
            string arg3 = @"k -map_metadata 0 -id3v2_version 3 -vn ";
            string fileout = Path.Combine(outputdisplay.Text, Path.GetFileNameWithoutExtension(inputdisplay.Text) + GetOutExtension());
            string arguments = arg + abytes + arg1 + inputdisplay.Text + arg2 + qlabel.Content + arg3 + fileout;

            Process ffm = new Process();
            ffm.StartInfo.FileName = ffdir;
            ffm.StartInfo.Arguments = arguments;
            ffm.StartInfo.CreateNoWindow = true;
            ffm.StartInfo.RedirectStandardError = true;
            ffm.StartInfo.UseShellExecute = false;
            ffm.StartInfo.WorkingDirectory = Directory.GetCurrentDirectory();
            ffm.EnableRaisingEvents = true;
            Console.SetOut(new TextBoxWriter(txtConsole));
            ffm.ErrorDataReceived += (s, ea) =>
            {
                Console.WriteLine($"{ea.Data}");
            };

            scrolltimer.Tick += new EventHandler(scrolltimer_Tick);
            scrolltimer.Interval = new TimeSpan(0, 0, 1);

            ffm.Start();

            ffm.BeginErrorReadLine();
            scrolltimer.Start();

            await Task.Run(() => ffm.WaitForExit());

            ffm.Close();

            inpbutton.IsEnabled = true;

            convertbutton.IsEnabled = true;

            scrolltimer.Stop();
            scrolltimer.Tick -= new EventHandler(scrolltimer_Tick);

            enrb();
            enbslst();

            statuslbl.Content = "Conversion Complete!";

            stopbar();

            Directory.Delete(resdir, true);
        }

See More Examples