本文整理汇总了C#中WorkItemState类的典型用法代码示例。如果您正苦于以下问题:C# WorkItemState类的具体用法?C# WorkItemState怎么用?C# WorkItemState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WorkItemState类属于命名空间,在下文中一共展示了WorkItemState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1:
public EmsWorkItem
(
decimal id,
int externalEntityId,
WorkItemState workItemState,
SubmissionPriority submissionPriority,
byte[] messageBody,
bool assigned,
bool isRetry,
string ownerName,
ContextIdentifier contextIdentifier,
EmsReaderQueue queue,
Message message
)
: base
(
id,
externalEntityId,
workItemState,
submissionPriority,
messageBody,
assigned,
isRetry,
ownerName,
contextIdentifier
)
{
this.queue = queue;
this.message = message;
}
示例2: WorkItem
/// <summary>
/// Construct a WorkItem for a particular test.
/// </summary>
/// <param name="test">The test that the WorkItem will run</param>
/// <param name="context">The TestExecutionContext in which it will run</param>
public WorkItem(Test test, TestExecutionContext context)
{
_test = test;
_testResult = test.MakeTestResult();
_state = WorkItemState.Ready;
_context = context;
}
示例3:
public ResponseWorkItem
(
long id,
int externalEntityId,
WorkItemState workItemState,
SubmissionPriority submissionPriority,
byte[] messageBody,
bool assigned,
bool isRetry,
string ownerName,
ContextIdentifier contextIdentifier
)
: base
(
id,
externalEntityId,
workItemState,
submissionPriority,
messageBody,
assigned,
isRetry,
ownerName,
contextIdentifier
)
{
}
示例4: GetDescription
public static string GetDescription(WorkItemState state)
{
string desc = (isJa) ? "�쐬�ς�" : "Created";
switch (state)
{
case WorkItemState.Created:
desc = (isJa) ? "�쐬�ς�" : "Created";
break;
case WorkItemState.Scheduled:
desc = (isJa) ? "�X�P�W���[���ς�" : "Scheduled";
break;
case WorkItemState.Queued:
desc = (isJa) ? "���[�N�L���[" : "Queued";
break;
case WorkItemState.Running:
desc = (isJa) ? "���s��" : "Running";
break;
case WorkItemState.Failed:
desc = (isJa) ? "���s" : "Failed";
break;
case WorkItemState.Completed:
desc = (isJa) ? "����" : "Completed";
break;
default:
break;
}
return desc;
}
示例5: WorkItem
/// <summary>
/// Construct a WorkItem for a particular test.
/// </summary>
/// <param name="test">The test that the WorkItem will run</param>
public WorkItem(Test test, FinallyDelegate finallyDelegate)
{
_test = test;
testResult = test.MakeTestResult();
_state = WorkItemState.Ready;
finD = finallyDelegate;
}
示例6: WorkItem
/// <summary>
/// Construct a WorkItem for a particular test.
/// </summary>
/// <param name="test">The test that the WorkItem will run</param>
/// <param name="context">The context to be used for running this test</param>
public WorkItem(Test test, TestExecutionContext context)
{
_test = test;
_context = context.Save();
testResult = test.MakeTestResult();
_command = test.GetTestCommand();
_state = WorkItemState.Ready;
}
示例7: IsValidStatesTransition
private static bool IsValidStatesTransition(WorkItemState currentState, WorkItemState nextState)
{
bool valid = false;
switch (currentState)
{
case WorkItemState.InQueue:
valid = (WorkItemState.InProgress == nextState) || (WorkItemState.Canceled == nextState);
break;
case WorkItemState.InProgress:
valid = (WorkItemState.Completed == nextState) || (WorkItemState.Canceled == nextState);
break;
case WorkItemState.Completed:
case WorkItemState.Canceled:
// Cannot be changed
break;
default:
// Unknown state
Debug.Assert(false);
break;
}
return valid;
}
示例8: WorkItemStateChanged
/// <summary>
/// Invoked by an <see cref="IWorkItem"/> to inform a work queue that its <see cref="IWorkItem.State"/>
/// has changed.
/// </summary>
/// <param name="workItem">
/// The <see cref="IWorkItem"/> that has changed <see cref="IWorkItem.State"/>.
/// </param>
/// <param name="previousState">
/// One of the <see cref="WorkItemState"/> values indicating the previous state of the <paramref name="workItem"/>.
/// </param>
/// <remarks>
/// The <see cref="ChangedWorkItemState"/> event is raised by calling the
/// <see cref="OnChangedWorkItemState"/> method. Then the following actions are performed,
/// based on the new <see cref="IWorkItem.State"/> of <paramref name="workItem"/>:
/// <list type="table">
/// <listheader>
/// <term>State</term>
/// <description>Action</description>
/// </listheader>
/// <item>
/// <term><see cref="WorkItemState">Scheduled</see></term>
/// <description>Assign the <paramref name="workItem"/> to the <see cref="WorkerPool"/>.</description>
/// </item>
/// <item>
/// <term><see cref="WorkItemState">Running</see></term>
/// <description>Raise the <see cref="RunningWorkItem"/> event.</description>
/// </item>
/// <item>
/// <term><see cref="WorkItemState">Failing</see></term>
/// <description>Raise the <see cref="FailedWorkItem"/> event.</description>
/// </item>
/// <item>
/// <term><see cref="WorkItemState">Completed</see></term>
/// <description>Raise the <see cref="CompletedWorkItem"/> event and schedule the next work item in the queue.</description>
/// </item>
/// </list>
/// </remarks>
public void WorkItemStateChanged(IWorkItem workItem, WorkItemState previousState)
{
OnChangedWorkItemState(workItem, previousState);
switch (workItem.State)
{
case WorkItemState.Scheduled:
lock (this)
{
// Housekeeping chores.
++runningItems;
// Now start it.
WorkerPool.BeginWork(workItem);
}
break;
case WorkItemState.Running:
OnRunningWorkItem(workItem);
break;
case WorkItemState.Failing:
OnFailedWorkItem(workItem);
break;
case WorkItemState.Completed:
bool allDone = false;
lock (this)
{
--runningItems;
allDone = queue.Count == 0 && runningItems == 0;
}
// Tell the world that the workitem has completed.
OnCompletedWorkItem(workItem);
// Find some more work.
if (allDone)
{
// Wakeup.
OnAllWorkCompleted(EventArgs.Empty);
lock (completed)
{
Monitor.PulseAll(completed);
}
}
else
{
DoNextWorkItem();
}
break;
}
}
示例9: WorkItemComplete
/// <summary>
/// Method called by the derived class when all work is complete
/// </summary>
protected void WorkItemComplete()
{
finD.Complete();
_state = WorkItemState.Complete;
if (Completed != null)
Completed(this, EventArgs.Empty);
}
示例10: SetWorkItemState
/// <summary>
/// Sets the work item's state
/// </summary>
/// <param name="workItemState">The state to set the work item to</param>
private void SetWorkItemState(WorkItemState workItemState)
{
lock(this)
{
_workItemState = workItemState;
}
}
示例11: Initialize
internal void Initialize()
{
_workItemState = WorkItemState.InQueue;
_workItemCompleted = null;
_workItemCompletedRefCount = 0;
}
示例12: WorkItem
/// <summary>
/// Construct a WorkItem for a particular test.
/// </summary>
/// <param name="test">The test that the WorkItem will run</param>
public WorkItem(Test test)
{
_test = test;
Result = test.MakeTestResult();
_state = WorkItemState.Ready;
}
示例13: RunTest
private void RunTest()
{
_context.CurrentTest = this.Test;
_context.CurrentResult = this.Result;
_context.Listener.TestStarted(this.Test);
_context.StartTime = DateTime.UtcNow;
_context.StartTicks = Stopwatch.GetTimestamp();
_context.EstablishExecutionEnvironment();
_state = WorkItemState.Running;
#if PORTABLE
PerformWork();
#else
try
{
PerformWork();
}
catch (ThreadAbortException)
{
//Result.SetResult(ResultState.Cancelled);
}
#endif
}
示例14: SetWorkItemState
/// <summary>
/// Sets the work item's state
/// </summary>
/// <param name="workItemState">The state to set the work item to</param>
private void SetWorkItemState(WorkItemState workItemState)
{
lock (this)
{
if (IsValidStatesTransition(_workItemState, workItemState))
{
_workItemState = workItemState;
}
}
}
示例15: GetWorkItemState
private WorkItemState GetWorkItemState()
{
lock (this)
{
if (WorkItemState.Completed == _workItemState)
{
return _workItemState;
}
long nowTicks = DateTime.UtcNow.Ticks;
if (WorkItemState.Canceled != _workItemState && nowTicks > _expirationTime)
{
_workItemState = WorkItemState.Canceled;
}
if (WorkItemState.InProgress == _workItemState)
{
return _workItemState;
}
if (CanceledSmartThreadPool.IsCanceled || CanceledWorkItemsGroup.IsCanceled)
{
return WorkItemState.Canceled;
}
return _workItemState;
}
}