System.Windows.Threading.DispatcherTimer.Stop C# (CSharp) Method

Stop() public method

public Stop ( ) : void
return void
		public void Stop ()
		{
			if (started) {
				started = false;
				Mono.NativeMethods.dispatcher_timer_stop (internalTimer.native);
			}
		}

Usage Example

        private void ExecuteWebRequest(string url, Action<string> callback, Action<Exception> error)
        {
            DispatcherTimer timer = new DispatcherTimer();

              // create a web client to fetch the URL results
              WebClient webClient = new WebClient();
              webClient.DownloadStringCompleted += (s, e) =>
              {
            timer.Stop();
            try
            {
              string result = e.Result;
              callback(result);
            }
            catch (Exception ex)
            {
              error(ex);
            }
              };

              // initiate the download
              webClient.DownloadStringAsync(new Uri(url));

              // create a timeout timer
              timer.Interval = TimeSpan.FromSeconds(5);
              timer.Start();
              timer.Tick += (s, e) =>
            {
              timer.Stop();
              webClient.CancelAsync();
              error(new TimeoutException());
            };
        }
All Usage Examples Of System.Windows.Threading.DispatcherTimer::Stop