當前位置: 首頁>>代碼示例>>C#>>正文


C# Task.GetNextInterval方法代碼示例

本文整理匯總了C#中System.Threading.Task.GetNextInterval方法的典型用法代碼示例。如果您正苦於以下問題:C# Task.GetNextInterval方法的具體用法?C# Task.GetNextInterval怎麽用?C# Task.GetNextInterval使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Threading.Task的用法示例。


在下文中一共展示了Task.GetNextInterval方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: AddTask

		/// <remarks>
		/// <b>Relative Scheduling</b>
		/// <tt>true</tt>:<br></br>
		/// Task is rescheduled relative to the last time it <i>actually</i>
		/// started execution
		///	<p>
		/// <tt>false</tt>:<br></br>
		/// Task is scheduled relative to its <i>last</i> execution schedule. This
		/// has the effect that the time between two consecutive executions of
		/// the task remains the same.
		/// </p>
		/// </remarks>
		/// <summary>
		/// Add a task for execution at adjustable intervals
		/// </summary>
		/// <param name="t">The task to execute</param>
		/// <param name="relative">Use relative scheduling</param>
		public void AddTask(Task t, bool relative) 
		{
			long interval;
			lock(this) 
			{
				if(thread_state == State.DISPOSED) return;
				if((interval = t.GetNextInterval()) < 0) return;

                queue.Push(new QueuedEvent(t));

				switch(thread_state) 
				{
					case State.RUN: break; 
					case State.SUSPEND: _unsuspend(); break;
					case State.STOPPING: break;
					case State.STOP: break;
				}
			}
		}
開發者ID:javithalion,項目名稱:NCache,代碼行數:36,代碼來源:TimeScheduler.cs


注:本文中的System.Threading.Task.GetNextInterval方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。