本文整理汇总了C#中IWorkItemsGroup.WaitForIdle方法的典型用法代码示例。如果您正苦于以下问题:C# IWorkItemsGroup.WaitForIdle方法的具体用法?C# IWorkItemsGroup.WaitForIdle怎么用?C# IWorkItemsGroup.WaitForIdle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWorkItemsGroup
的用法示例。
在下文中一共展示了IWorkItemsGroup.WaitForIdle方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: QuickSort
/// <summary>
/// QuickSort array using wig to parallel the sort
/// </summary>
/// <param name="wig">A IWorkItemsGroup to use to parallel the sort</param>
/// <param name="array">The array of items to sort</param>
public static void QuickSort(IWorkItemsGroup wig, int[] array)
{
// Initiate the QuickSort
wig.QueueWorkItem(QuickSort, wig, array, 0, array.Length - 1);
// Wait for the sort to complete.
wig.WaitForIdle();
}
示例2: TestQueueWorkItemCallStatPostPrio
//IWorkItemResult QueueWorkItem(WorkItemCallback callback, object state, PostExecuteWorkItemCallback postExecuteWorkItemCallback, WorkItemPriority workItemPriority);
public static void TestQueueWorkItemCallStatPostPrio(IWorkItemsGroup wig)
{
bool postExecuteCalled = false;
object state = new object();
PostExecuteWorkItemCallback postExecuteWorkItemCallback = delegate(IWorkItemResult w) { postExecuteCalled = true; };
WorkItemInfo wii = new WorkItemInfo();
wii.WorkItemPriority = WorkItemPriority.BelowNormal;
wii.PostExecuteWorkItemCallback = postExecuteWorkItemCallback;
WorkItemInfoComparer wiic = new WorkItemInfoComparer(wii, state);
IWorkItemResult wir = wig.QueueWorkItem(
wiic.CompareWorkItemInfo,
state,
postExecuteWorkItemCallback,
WorkItemPriority.BelowNormal);
// We must wait for idle to let the post execute run
wig.WaitForIdle();
bool success = (bool)wir.Result;
Assert.IsTrue(success);
Assert.IsTrue(postExecuteCalled);
}
示例3: TestQueueWorkItemInfoCallStat
//IWorkItemResult QueueWorkItem(WorkItemInfo workItemInfo, WorkItemCallback callback, object state);
public static void TestQueueWorkItemInfoCallStat(IWorkItemsGroup wig)
{
object state = new object();
WorkItemInfo wii = new WorkItemInfo();
wii.CallToPostExecute = CallToPostExecute.Never;
wii.DisposeOfStateObjects = true;
wii.PostExecuteWorkItemCallback = delegate(IWorkItemResult w) { };
wii.UseCallerCallContext = true;
wii.UseCallerHttpContext = true;
wii.WorkItemPriority = WorkItemPriority.Highest;
WorkItemInfoComparer wiic = new WorkItemInfoComparer(wii, state);
IWorkItemResult wir = wig.QueueWorkItem(wii, wiic.CompareWorkItemInfo, state);
// We must wait for idle to let the post execute run
wig.WaitForIdle();
bool success = (bool)wir.Result;
Assert.IsTrue(success);
}
示例4: TestQueueWorkItemCallStatPostPflgPrio
//IWorkItemResult QueueWorkItem(WorkItemCallback callback, object state, PostExecuteWorkItemCallback postExecuteWorkItemCallback, CallToPostExecute callToPostExecute, WorkItemPriority workItemPriority);
public static void TestQueueWorkItemCallStatPostPflgPrio(IWorkItemsGroup wig)
{
bool postExecuteCalled;
CallToPostExecute callToPostExecute;
object state = new object();
PostExecuteWorkItemCallback postExecuteWorkItemCallback = delegate(IWorkItemResult w) { postExecuteCalled = true; };
WorkItemInfo wii = new WorkItemInfo();
wii.PostExecuteWorkItemCallback = postExecuteWorkItemCallback;
WorkItemInfoComparer wiic = new WorkItemInfoComparer(wii, state);
WorkItemPriority workItemPriority;
IWorkItemResult wir;
bool success;
/////////////////////////////////////////////////////////////////////////////
callToPostExecute = CallToPostExecute.Always;
workItemPriority = WorkItemPriority.Lowest;
// Check without cancel
postExecuteCalled = false;
wiic.SleepTime = 0;
wii.CallToPostExecute = callToPostExecute;
wii.WorkItemPriority = workItemPriority;
wir = wig.QueueWorkItem(
wiic.CompareWorkItemInfo,
state,
postExecuteWorkItemCallback,
callToPostExecute,
workItemPriority);
// We must wait for idle to let the post execute run
wig.WaitForIdle();
success = (bool)wir.Result;
Assert.IsTrue(success);
Assert.IsTrue(postExecuteCalled);
// Check with cancel
success = false;
postExecuteCalled = false;
wiic.SleepTime = 100;
wir = wig.QueueWorkItem(
wiic.CompareWorkItemInfo,
state,
postExecuteWorkItemCallback,
callToPostExecute,
workItemPriority);
wir.Cancel();
// We must wait for idle to let the post execute run
wig.WaitForIdle();
Assert.IsTrue(postExecuteCalled);
try
{
wir.GetResult();
}
catch (WorkItemCancelException ce)
{
success = true;
}
Assert.IsTrue(success);
/////////////////////////////////////////////////////////////////////////////
callToPostExecute = CallToPostExecute.Never;
workItemPriority = WorkItemPriority.Highest;
postExecuteCalled = false;
wiic.SleepTime = 0;
wii.CallToPostExecute = callToPostExecute;
wii.WorkItemPriority = workItemPriority;
wir = wig.QueueWorkItem(
wiic.CompareWorkItemInfo,
state,
postExecuteWorkItemCallback,
callToPostExecute,
workItemPriority);
// We must wait for idle to let the post execute run
wig.WaitForIdle();
success = (bool)wir.Result;
Assert.IsTrue(success);
Assert.IsFalse(postExecuteCalled);
// Check with cancel
success = false;
postExecuteCalled = false;
//.........这里部分代码省略.........