/// <summary>
		///		STop the timer.
		/// </summary>
		/// <param name="timer">
		///		The timer.
		/// </param>
		public static void Stop(this Timer timer)
		{
			if (timer == null)
				throw new ArgumentNullException(nameof(timer));

			timer.Change(TimeSpan.Zero, TimeSpan.Zero);
		}
Esempio n. 2
0
 /// <summary>
 /// Function to set timer time to specific time.
 /// </summary>
 /// <param name="timer">Object of type Timer</param>
 /// <param name="dueTime">Timer due time</param>
 /// <param name="period">Timer due period</param>
 /// <returns>True or false</returns>
 public static bool ChangeInterval(this Timer timer, int dueTime, int period)
 {
     using (var task = new Task(() => timer.Change(dueTime, period)))
     {
         task.RunSynchronously();
         LogException(task.Exception);
         return !task.IsFaulted;
     }
 } 
		/// <summary>
		///		Start the timer.
		/// </summary>
		/// <param name="timer">
		///		The timer.
		/// </param>
		/// <param name="period">
		///		A <see cref="TimeSpan"/> representing the span of time between successive invocations of the timer callback.
		/// </param>
		public static void Start(this Timer timer, TimeSpan period)
		{
			if (timer == null)
				throw new ArgumentNullException(nameof(timer));

			if (period == TimeSpan.Zero)
				throw new ArgumentOutOfRangeException(nameof(period), period, "Timer period cannot be 0.");

			timer.Change(TimeSpan.Zero, period);
		}
        public static SemVersion IncrementBuildNumber(this SemVersion version)
        {
            int buildNumber;
            if (int.TryParse(version.Build, out buildNumber))
            {
                buildNumber++;
                return version.Change(build: (buildNumber).ToString());
            }

            return version;
        }
Esempio n. 5
0
 public static void StopTimer(this Timer timer)
 {
     if (timer != null)
     {
         try
         {
             timer.Change(Timeout.InfiniteTimeSpan, Timeout.InfiniteTimeSpan);
         }
         catch { }
     }
 }
Esempio n. 6
0
 public static void StartTimer(this Timer timer, int interval)
 {
     if (timer != null)
     {
         try
         {
             timer.Change(TimeSpan.FromSeconds(interval), TimeSpan.FromSeconds(interval));
         }
         catch { }
     }
 }
Esempio n. 7
0
        public static void CloseTimer(this Timer timer)
        {
            if (timer != null)
            {
                try
                {
                    timer.Change(Timeout.InfiniteTimeSpan, Timeout.InfiniteTimeSpan);
                }
                catch { }

                try
                {
                    timer.Dispose();
                }
                catch { }

                timer = null;
            }
        }
Esempio n. 8
0
		public static void Next(this Timer timer, TimeSpan dueTime)
		{
			timer.Change(dueTime, TimeSpan.FromMilliseconds(Timeout.Infinite));
		}
Esempio n. 9
0
 public static void DelayedStart(this Timer timer, int delayTime)
 {
     timer.Change(delayTime, Timeout.Infinite);
 }
 public static bool Change(this Timer timer, TimeSpan? interval)
 {
     return timer.Change(interval ?? Infinite, interval ?? Infinite);
 }
 public static SemVersion IncrementPatchNumber(this SemVersion version)
 {
     return version.Change(patch: version.Patch + 1);
 }
 public static void SetBuildNumber(this SemVersion version, int buildNumber)
 {
     version.Change(build: buildNumber.ToString());
 }
 public static void Restart(this Timer argThis, TimeSpan argInterval)
 {
     argThis.Change(argInterval, argInterval);
 }
 public static void Stop(this Timer argThis)
 {
     argThis.Change(Timeout.Infinite, Timeout.Infinite);
 }
 public static bool Stop(this Timer timer)
 {
     return timer.Change(Infinite, Infinite);
 }
Esempio n. 16
0
 public static void Stop(this Timer timer)
 {
     timer.Change(Timeout.Infinite, Timeout.Infinite);
 }
Esempio n. 17
0
 /// <summary>
 /// Function to set timer time to specific time.
 /// </summary>
 /// <param name="timer">Object of type Timer</param>
 /// <param name="dueTime">Timer due time</param>
 /// <param name="period">Timer due period</param>
 /// <returns>True or false</returns>
 public static bool ChangeInterval(this Timer timer, int dueTime, int period)
 {
     return timer != null && timer.Change(dueTime, period);
 }