WorkflowInstance.EnqueueItemOnIdle 메서드

정의

워크플로가 유휴 상태이면 메시지를 지정된 워크플로 큐에 게시합니다. EnqueueItemOnIdle(IComparable, Object, IPendingWork, Object)은 워크플로가 유휴 지점에 도달할 때까지 기다리고 워크플로 스케줄러가 유휴 상태인지, 즉 실행 중인 활성 작업이 없는지 확인한 후 큐에 삽입됩니다.

public:
 void EnqueueItemOnIdle(IComparable ^ queueName, System::Object ^ item, System::Workflow::Runtime::IPendingWork ^ pendingWork, System::Object ^ workItem);
public void EnqueueItemOnIdle (IComparable queueName, object item, System.Workflow.Runtime.IPendingWork pendingWork, object workItem);
member this.EnqueueItemOnIdle : IComparable * obj * System.Workflow.Runtime.IPendingWork * obj -> unit
Public Sub EnqueueItemOnIdle (queueName As IComparable, item As Object, pendingWork As IPendingWork, workItem As Object)

매개 변수

queueName
IComparable

WorkflowQueue의 이름입니다.

item
Object

큐에 삽입할 개체입니다.

pendingWork
IPendingWork

IPendingWork이 전달되면 발신자에게 알리는 item입니다.

workItem
Object

IPendingWork 메서드에 전달할 개체입니다.

예외

queueName이 null 참조(Visual Basic의 경우 Nothing)인 경우

워크플로 런타임 엔진이 실행되고 있지 않은 경우

또는 워크플로 인스턴스가 일시 중단된 경우

또는 WorkflowQueue에 지정된 queueName가 없는 경우

또는 WorkflowQueue에 지정된 queueName를 사용할 수 없는 경우

예제

다음 예제에서는 EnqueueItemOnIdle 메서드를 사용하여 정보를 워크플로 인스턴스로 보내는 방법을 보여 줍니다. 먼저 WorkflowInstance 개체를 만들어 시작한 다음 IPendingWork 인터페이스를 구현하는 개체를 만듭니다. EnqueueItemOnIdle 그런 다음 라고, 큐 이름, 큐에 넣은 항목 및 pendingWork 개체의 메서드에 전달할 작업 항목에 대 한 문자열 값을 전달 합니다.

// Create a workflow runtime environment
WorkflowRuntime workflowRuntime = new WorkflowRuntime();
// Create a new instance of the out-of-box SqlWorkflowPersistenceService.
// Use the non-locking constructor, since we're only creating a single Workflow Runtime.
NameValueCollection parameters = new NameValueCollection();
parameters.Add("ConnectionString",
    "Initial Catalog=SqlPersistenceService;Data Source=localhost;Integrated Security=SSPI;");
//Set UnloadOnIdle to true, so that the service will persist the workflow
parameters.Add("UnloadOnIdle", "true");
SqlWorkflowPersistenceService persistenceService =
   new SqlWorkflowPersistenceService(parameters);

// Add the service to the runtime
workflowRuntime.AddService(persistenceService);
// Create a WorkflowInstance object
WorkflowInstance workflowInstance = workflowRuntime.CreateWorkflow(typeof(Workflow1));
// Start the instance
workflowInstance.Start();
// Create an instance of a class that implements IPendingWork for notification
PendingService pendingWork = new PendingService();
// Send the workflow the message
workflowInstance.EnqueueItemOnIdle("ActionQueue", "StartWork", pendingWork, "ActionItem");
' Create a workflow runtime environment
Dim workflowRuntime As New WorkflowRuntime()
' Create a new instance of the out-of-box SqlWorkflowPersistenceService.
' Use the non-locking constructor, since we're only creating a single Workflow Runtime.
Dim parameters As New NameValueCollection()
parameters.Add("ConnectionString", _
    "Initial Catalog=SqlPersistenceServiceData Source=localhostIntegrated Security=SSPI")
'Set UnloadOnIdle to true, so that the service will persist the workflow
parameters.Add("UnloadOnIdle", "true")
Dim persistenceService As _
   New SqlWorkflowPersistenceService(parameters)

' Add the service to the runtime
workflowRuntime.AddService(persistenceService)
' Create a WorkflowInstance object
Dim workflowInstance As WorkflowInstance = workflowRuntime.CreateWorkflow(GetType(Workflow1))
' Start the instance
workflowInstance.Start()
' Create an instance of a class that implements IPendingWork for notification
Dim pendingWork As New PendingService()
' Send the workflow the message
workflowInstance.EnqueueItemOnIdle("ActionQueue", "StartWork", pendingWork, "ActionItem")

설명

워크플로 인스턴스가 유휴 상태가 될 때까지 기다린 후 item을 지정된 WorkflowQueue로 보냅니다. 워크플로 인스턴스가 일시 중단된 동안 EnqueueItemOnIdle을 호출하면 워크플로 런타임 엔진이 InvalidOperationException을 throw합니다. 메시지가 전달될 때 알림을 받으려면 서비스에 IPendingWork를 구현하고 workItemIPendingWork 개체를 EnqueueItem으로 전달합니다. 해당 알림을 원하지 않는 경우 NothingpendingWork에 대해 null 참조(Visual Basic의 경우 workItem)를 전달할 수 있습니다.

상태 시스템 워크플로 사용 하 여이 메서드를 사용 하는 경우 메시지를 포함 하는 예외가 발생할 수 있습니다 "큐 '{0}' 사용할 수 없습니다." 이 예외는 상태 시스템의 현재 상태에서 특정 이벤트를 처리하는 방법을 모르고 있기 때문입니다. 예를 들어 현재 상태 이외의 일부 상태에 '{0}' 큐에서 나타내는 EventDrivenActivity를 포함하는 HandleExternalEventActivity가 있습니다.

적용 대상