WorkflowInvoker.InvokeAsync 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
이벤트 기반 비동기 디자인 패턴을 사용하여 워크플로를 비동기적으로 호출합니다.
오버로드
| Name | Description |
|---|---|
| InvokeAsync(TimeSpan, Object) |
지정된 제한 시간 간격 및 고유 식별자를 사용하여 워크플로를 비동기적으로 호출합니다. |
| InvokeAsync(IDictionary<String,Object>, TimeSpan) |
지정된 입력 매개 변수 및 지정된 IDictionary<TKey,TValue> 제한 시간 간격을 사용하여 워크플로를 비동기적으로 호출합니다. |
| InvokeAsync(IDictionary<String,Object>, Object) |
지정된 IDictionary<TKey,TValue> 입력 매개 변수 및 고유 식별자를 사용하여 워크플로를 비동기적으로 호출합니다. |
| InvokeAsync() |
워크플로를 비동기적으로 호출합니다. |
| InvokeAsync(Object) |
지정된 고유 식별자를 사용하여 워크플로를 비동기적으로 호출합니다. |
| InvokeAsync(IDictionary<String,Object>) |
지정된 IDictionary<TKey,TValue> 입력 매개 변수를 사용하여 워크플로를 비동기적으로 호출합니다. |
| InvokeAsync(IDictionary<String,Object>, TimeSpan, Object) |
지정된 입력 매개 변수, 지정된 IDictionary<TKey,TValue> 제한 시간 간격 및 고유 식별자를 사용하여 워크플로를 비동기적으로 호출합니다. |
| InvokeAsync(TimeSpan) |
지정된 제한 시간 간격으로 워크플로를 비동기적으로 호출합니다. |
설명
워크플로가 완료될 때 알림을 받도록 하려면 .를 처리합니다 InvokeCompleted. 워크플로가 완료되어야 하는 제한 시간 간격을 구성하려면 다음을 수행하는 TimeSpan오버로드 중 InvokeAsync 하나를 사용합니다.
이 메서드는 이벤트 기반 비동기 디자인 패턴을 사용하여 워크플로를 비동기적으로 호출합니다. 자세한 내용은 이벤트 기반 비동기 패턴 개요를 참조하세요.
InvokeAsync(TimeSpan, Object)
지정된 제한 시간 간격 및 고유 식별자를 사용하여 워크플로를 비동기적으로 호출합니다.
public:
void InvokeAsync(TimeSpan timeout, System::Object ^ userState);
public void InvokeAsync(TimeSpan timeout, object userState);
member this.InvokeAsync : TimeSpan * obj -> unit
Public Sub InvokeAsync (timeout As TimeSpan, userState As Object)
매개 변수
- timeout
- TimeSpan
워크플로가 중단되고 throw되기 전에 완료해야 하는 TimeoutException 간격입니다.
- userState
- Object
이 특정 비동기 호출 작업을 다른 현재 비동기 호출 작업과 구분하는 데 사용되는 사용자 제공 개체입니다.
예제
다음 예제에서는 활동으로 구성된 워크플로를 LongRunningDiceRoll 호출합니다.
LongRunningDiceRoll 작업에는 주사위 롤 작업의 결과를 나타내는 두 개의 출력 인수가 있습니다. 워크플로가 완료되면 처리기에서 InvokeCompleted 검색됩니다.
public sealed class LongRunningDiceRoll : Activity
{
public OutArgument<int> D1 { get; set; }
public OutArgument<int> D2 { get; set; }
public LongRunningDiceRoll()
{
this.Implementation = () => new Sequence
{
Activities =
{
new WriteLine
{
Text = "Rolling the dice for 5 seconds."
},
new Delay
{
Duration = TimeSpan.FromSeconds(5)
},
new DiceRoll
{
D1 = new OutArgument<int>(env => this.D1.Get(env)),
D2 = new OutArgument<int>(env => this.D2.Get(env))
}
}
};
}
}
AutoResetEvent syncEvent = new AutoResetEvent(false);
WorkflowInvoker invoker = new WorkflowInvoker(new LongRunningDiceRoll());
invoker.InvokeCompleted += delegate(object sender, InvokeCompletedEventArgs args)
{
if (args.Cancelled)
{
Console.WriteLine("Workflow was cancelled.");
}
else if (args.Error != null)
{
Console.WriteLine("Exception: {0}\n{1}",
args.Error.GetType().FullName,
args.Error.Message);
}
else
{
Console.WriteLine("The two dice are {0} and {1}.",
args.Outputs["D1"], args.Outputs["D2"]);
}
syncEvent.Set();
};
invoker.InvokeAsync("InvokeAsync Example");
Console.WriteLine("Waiting for the workflow to complete.");
// Wait for the workflow to complete.
syncEvent.WaitOne();
Console.WriteLine("The workflow is complete.");
설명
매개 변수는 userState 현재 작업에 대해 현재 실행 중인 InvokeAsync 모든 작업에서 고유해야 합니다. 고유하지 않으면 userState throw ArgumentException 됩니다.
userState 는 에서 워크플로 InvokeCompleted를 식별하고 .를 사용하여 CancelAsync워크플로를 취소하는 데 사용됩니다.
워크플로가 완료될 때 알림을 받도록 하려면 .를 처리합니다 InvokeCompleted. 워크플로가 지정된 제한 시간 간격 내에 완료되지 않으면 워크플로가 중단되고 throw TimeoutException 됩니다.
메모
TimeoutException 시간 제한 간격이 경과하고 실행 중에 워크플로가 유휴 상태가 되는 경우에만 throw됩니다. 워크플로가 유휴 상태가 되지 않으면 완료하는 데 지정된 시간 제한 간격보다 더 오래 걸리는 워크플로가 성공적으로 완료됩니다.
이 메서드는 이벤트 기반 비동기 디자인 패턴을 사용하여 워크플로를 비동기적으로 호출합니다. 자세한 내용은 이벤트 기반 비동기 패턴 개요를 참조하세요.
적용 대상
InvokeAsync(IDictionary<String,Object>, TimeSpan)
지정된 입력 매개 변수 및 지정된 IDictionary<TKey,TValue> 제한 시간 간격을 사용하여 워크플로를 비동기적으로 호출합니다.
public:
void InvokeAsync(System::Collections::Generic::IDictionary<System::String ^, System::Object ^> ^ inputs, TimeSpan timeout);
public void InvokeAsync(System.Collections.Generic.IDictionary<string,object> inputs, TimeSpan timeout);
member this.InvokeAsync : System.Collections.Generic.IDictionary<string, obj> * TimeSpan -> unit
Public Sub InvokeAsync (inputs As IDictionary(Of String, Object), timeout As TimeSpan)
매개 변수
- inputs
- IDictionary<String,Object>
인수 이름으로 키가 지정된 워크플로에 대한 입력 매개 변수의 사전입니다.
- timeout
- TimeSpan
워크플로가 중단되고 throw되기 전에 완료해야 하는 TimeoutException 간격입니다.
예제
다음 예제에서는 활동으로 구성된 워크플로를 LongRunningDiceRoll 호출합니다.
LongRunningDiceRoll 작업에는 주사위 롤 작업의 결과를 나타내는 두 개의 출력 인수가 있습니다. 워크플로가 완료되면 처리기에서 InvokeCompleted 검색됩니다.
public sealed class LongRunningDiceRoll : Activity
{
public OutArgument<int> D1 { get; set; }
public OutArgument<int> D2 { get; set; }
public LongRunningDiceRoll()
{
this.Implementation = () => new Sequence
{
Activities =
{
new WriteLine
{
Text = "Rolling the dice for 5 seconds."
},
new Delay
{
Duration = TimeSpan.FromSeconds(5)
},
new DiceRoll
{
D1 = new OutArgument<int>(env => this.D1.Get(env)),
D2 = new OutArgument<int>(env => this.D2.Get(env))
}
}
};
}
}
AutoResetEvent syncEvent = new AutoResetEvent(false);
WorkflowInvoker invoker = new WorkflowInvoker(new LongRunningDiceRoll());
invoker.InvokeCompleted += delegate(object sender, InvokeCompletedEventArgs args)
{
if (args.Cancelled)
{
Console.WriteLine("Workflow was cancelled.");
}
else if (args.Error != null)
{
Console.WriteLine("Exception: {0}\n{1}",
args.Error.GetType().FullName,
args.Error.Message);
}
else
{
Console.WriteLine("The two dice are {0} and {1}.",
args.Outputs["D1"], args.Outputs["D2"]);
}
syncEvent.Set();
};
invoker.InvokeAsync("InvokeAsync Example");
Console.WriteLine("Waiting for the workflow to complete.");
// Wait for the workflow to complete.
syncEvent.WaitOne();
Console.WriteLine("The workflow is complete.");
설명
워크플로가 완료될 때 알림을 받도록 하려면 .를 처리합니다 InvokeCompleted. 워크플로가 지정된 제한 시간 간격 내에 완료되지 않으면 워크플로가 중단되고 throw TimeoutException 됩니다.
메모
TimeoutException 시간 제한 간격이 경과하고 실행 중에 워크플로가 유휴 상태가 되는 경우에만 throw됩니다. 워크플로가 유휴 상태가 되지 않으면 완료하는 데 지정된 시간 제한 간격보다 더 오래 걸리는 워크플로가 성공적으로 완료됩니다.
이 메서드는 이벤트 기반 비동기 디자인 패턴을 사용하여 워크플로를 비동기적으로 호출합니다. 자세한 내용은 이벤트 기반 비동기 패턴 개요를 참조하세요.
이 메서드는 메서드의 동기 대응이 throw할 수 있는 모든 비사용 예외를 반환하는 작업에 저장됩니다. 예외가 반환된 작업에 저장되면 태스크가 대기될 때 해당 예외가 throw됩니다. ArgumentException같은 사용 예외는 여전히 동기적으로 던져집니다. 저장된 예외는 .에 의해 Invoke(IDictionary<String,Object>, TimeSpan)throw된 예외를 참조하세요.
적용 대상
InvokeAsync(IDictionary<String,Object>, Object)
지정된 IDictionary<TKey,TValue> 입력 매개 변수 및 고유 식별자를 사용하여 워크플로를 비동기적으로 호출합니다.
public:
void InvokeAsync(System::Collections::Generic::IDictionary<System::String ^, System::Object ^> ^ inputs, System::Object ^ userState);
public void InvokeAsync(System.Collections.Generic.IDictionary<string,object> inputs, object userState);
member this.InvokeAsync : System.Collections.Generic.IDictionary<string, obj> * obj -> unit
Public Sub InvokeAsync (inputs As IDictionary(Of String, Object), userState As Object)
매개 변수
- inputs
- IDictionary<String,Object>
인수 이름으로 키가 지정된 워크플로에 대한 입력 매개 변수의 사전입니다.
- userState
- Object
이 특정 비동기 호출 작업을 다른 현재 비동기 호출 작업과 구분하는 데 사용되는 사용자 제공 개체입니다.
예제
다음 예제에서는 활동으로 구성된 워크플로를 LongRunningDiceRoll 호출합니다.
LongRunningDiceRoll 작업에는 주사위 롤 작업의 결과를 나타내는 두 개의 출력 인수가 있습니다. 워크플로가 완료되면 처리기에서 InvokeCompleted 검색됩니다.
public sealed class LongRunningDiceRoll : Activity
{
public OutArgument<int> D1 { get; set; }
public OutArgument<int> D2 { get; set; }
public LongRunningDiceRoll()
{
this.Implementation = () => new Sequence
{
Activities =
{
new WriteLine
{
Text = "Rolling the dice for 5 seconds."
},
new Delay
{
Duration = TimeSpan.FromSeconds(5)
},
new DiceRoll
{
D1 = new OutArgument<int>(env => this.D1.Get(env)),
D2 = new OutArgument<int>(env => this.D2.Get(env))
}
}
};
}
}
AutoResetEvent syncEvent = new AutoResetEvent(false);
WorkflowInvoker invoker = new WorkflowInvoker(new LongRunningDiceRoll());
invoker.InvokeCompleted += delegate(object sender, InvokeCompletedEventArgs args)
{
if (args.Cancelled)
{
Console.WriteLine("Workflow was cancelled.");
}
else if (args.Error != null)
{
Console.WriteLine("Exception: {0}\n{1}",
args.Error.GetType().FullName,
args.Error.Message);
}
else
{
Console.WriteLine("The two dice are {0} and {1}.",
args.Outputs["D1"], args.Outputs["D2"]);
}
syncEvent.Set();
};
invoker.InvokeAsync("InvokeAsync Example");
Console.WriteLine("Waiting for the workflow to complete.");
// Wait for the workflow to complete.
syncEvent.WaitOne();
Console.WriteLine("The workflow is complete.");
설명
매개 변수는 userState 현재 작업에 대해 현재 실행 중인 InvokeAsync 모든 작업에서 고유해야 합니다. 고유하지 않으면 userState throw ArgumentException 됩니다.
userState 는 에서 워크플로 InvokeCompleted를 식별하고 .를 사용하여 CancelAsync워크플로를 취소하는 데 사용됩니다.
워크플로가 완료될 때 알림을 받도록 하려면 .를 처리합니다 InvokeCompleted. 워크플로가 완료되어야 하는 제한 시간 간격을 구성하려면 다음을 수행하는 TimeSpan오버로드 중 InvokeAsync 하나를 사용합니다.
이 메서드는 이벤트 기반 비동기 디자인 패턴을 사용하여 워크플로를 비동기적으로 호출합니다. 자세한 내용은 이벤트 기반 비동기 패턴 개요를 참조하세요.
적용 대상
InvokeAsync()
워크플로를 비동기적으로 호출합니다.
public:
void InvokeAsync();
public void InvokeAsync();
member this.InvokeAsync : unit -> unit
Public Sub InvokeAsync ()
예제
다음 예제에서는 활동으로 구성된 워크플로를 LongRunningDiceRoll 호출합니다.
LongRunningDiceRoll 작업에는 주사위 롤 작업의 결과를 나타내는 두 개의 출력 인수가 있습니다. 워크플로가 완료되면 처리기에서 InvokeCompleted 검색됩니다.
public sealed class LongRunningDiceRoll : Activity
{
public OutArgument<int> D1 { get; set; }
public OutArgument<int> D2 { get; set; }
public LongRunningDiceRoll()
{
this.Implementation = () => new Sequence
{
Activities =
{
new WriteLine
{
Text = "Rolling the dice for 5 seconds."
},
new Delay
{
Duration = TimeSpan.FromSeconds(5)
},
new DiceRoll
{
D1 = new OutArgument<int>(env => this.D1.Get(env)),
D2 = new OutArgument<int>(env => this.D2.Get(env))
}
}
};
}
}
AutoResetEvent syncEvent = new AutoResetEvent(false);
WorkflowInvoker invoker = new WorkflowInvoker(new LongRunningDiceRoll());
invoker.InvokeCompleted += delegate(object sender, InvokeCompletedEventArgs args)
{
if (args.Cancelled)
{
Console.WriteLine("Workflow was cancelled.");
}
else if (args.Error != null)
{
Console.WriteLine("Exception: {0}\n{1}",
args.Error.GetType().FullName,
args.Error.Message);
}
else
{
Console.WriteLine("The two dice are {0} and {1}.",
args.Outputs["D1"], args.Outputs["D2"]);
}
syncEvent.Set();
};
invoker.InvokeAsync("InvokeAsync Example");
Console.WriteLine("Waiting for the workflow to complete.");
// Wait for the workflow to complete.
syncEvent.WaitOne();
Console.WriteLine("The workflow is complete.");
설명
워크플로가 완료될 때 알림을 받도록 하려면 .를 처리합니다 InvokeCompleted. 워크플로가 완료되어야 하는 제한 시간 간격을 구성하려면 다음을 수행하는 TimeSpan오버로드 중 InvokeAsync 하나를 사용합니다.
이 메서드는 이벤트 기반 비동기 디자인 패턴을 사용하여 워크플로를 비동기적으로 호출합니다. 자세한 내용은 이벤트 기반 비동기 패턴 개요를 참조하세요.
이 메서드는 메서드의 동기 대응이 throw할 수 있는 모든 비사용 예외를 반환하는 작업에 저장됩니다. 예외가 반환된 작업에 저장되면 태스크가 대기될 때 해당 예외가 throw됩니다. ArgumentException같은 사용 예외는 여전히 동기적으로 던져집니다. 저장된 예외는 .에 의해 Invoke()throw된 예외를 참조하세요.
적용 대상
InvokeAsync(Object)
지정된 고유 식별자를 사용하여 워크플로를 비동기적으로 호출합니다.
public:
void InvokeAsync(System::Object ^ userState);
public void InvokeAsync(object userState);
member this.InvokeAsync : obj -> unit
Public Sub InvokeAsync (userState As Object)
매개 변수
- userState
- Object
이 특정 비동기 호출 작업을 다른 현재 비동기 호출 작업과 구분하는 데 사용되는 사용자 제공 개체입니다.
예제
다음 예제에서는 활동으로 구성된 워크플로를 LongRunningDiceRoll 호출합니다.
LongRunningDiceRoll 작업에는 주사위 롤 작업의 결과를 나타내는 두 개의 출력 인수가 있습니다. 워크플로가 완료되면 처리기에서 InvokeCompleted 검색됩니다.
public sealed class LongRunningDiceRoll : Activity
{
public OutArgument<int> D1 { get; set; }
public OutArgument<int> D2 { get; set; }
public LongRunningDiceRoll()
{
this.Implementation = () => new Sequence
{
Activities =
{
new WriteLine
{
Text = "Rolling the dice for 5 seconds."
},
new Delay
{
Duration = TimeSpan.FromSeconds(5)
},
new DiceRoll
{
D1 = new OutArgument<int>(env => this.D1.Get(env)),
D2 = new OutArgument<int>(env => this.D2.Get(env))
}
}
};
}
}
AutoResetEvent syncEvent = new AutoResetEvent(false);
WorkflowInvoker invoker = new WorkflowInvoker(new LongRunningDiceRoll());
invoker.InvokeCompleted += delegate(object sender, InvokeCompletedEventArgs args)
{
if (args.Cancelled)
{
Console.WriteLine("Workflow was cancelled.");
}
else if (args.Error != null)
{
Console.WriteLine("Exception: {0}\n{1}",
args.Error.GetType().FullName,
args.Error.Message);
}
else
{
Console.WriteLine("The two dice are {0} and {1}.",
args.Outputs["D1"], args.Outputs["D2"]);
}
syncEvent.Set();
};
invoker.InvokeAsync("InvokeAsync Example");
Console.WriteLine("Waiting for the workflow to complete.");
// Wait for the workflow to complete.
syncEvent.WaitOne();
Console.WriteLine("The workflow is complete.");
설명
매개 변수는 userState 현재 작업에 대해 현재 실행 중인 InvokeAsync 모든 작업에서 고유해야 합니다. 매개 변수가 userState 고유하지 않으면 throw ArgumentException 됩니다.
userState 는 에서 워크플로 InvokeCompleted를 식별하고 .를 사용하여 CancelAsync워크플로를 취소하는 데 사용됩니다.
워크플로가 완료될 때 알림을 받도록 하려면 .를 처리합니다 InvokeCompleted. 워크플로가 완료되어야 하는 제한 시간 간격을 구성하려면 다음을 수행하는 TimeSpan오버로드 중 InvokeAsync 하나를 사용합니다.
이 메서드는 이벤트 기반 비동기 디자인 패턴을 사용하여 워크플로를 비동기적으로 호출합니다. 자세한 내용은 이벤트 기반 비동기 패턴 개요를 참조하세요.
적용 대상
InvokeAsync(IDictionary<String,Object>)
지정된 IDictionary<TKey,TValue> 입력 매개 변수를 사용하여 워크플로를 비동기적으로 호출합니다.
public:
void InvokeAsync(System::Collections::Generic::IDictionary<System::String ^, System::Object ^> ^ inputs);
public void InvokeAsync(System.Collections.Generic.IDictionary<string,object> inputs);
member this.InvokeAsync : System.Collections.Generic.IDictionary<string, obj> -> unit
Public Sub InvokeAsync (inputs As IDictionary(Of String, Object))
매개 변수
- inputs
- IDictionary<String,Object>
인수 이름으로 키가 지정된 워크플로에 대한 입력 매개 변수의 사전입니다.
예제
다음 예제에서는 활동으로 구성된 워크플로를 LongRunningDiceRoll 호출합니다.
LongRunningDiceRoll 작업에는 주사위 롤 작업의 결과를 나타내는 두 개의 출력 인수가 있습니다. 워크플로가 완료되면 처리기에서 InvokeCompleted 검색됩니다.
public sealed class LongRunningDiceRoll : Activity
{
public OutArgument<int> D1 { get; set; }
public OutArgument<int> D2 { get; set; }
public LongRunningDiceRoll()
{
this.Implementation = () => new Sequence
{
Activities =
{
new WriteLine
{
Text = "Rolling the dice for 5 seconds."
},
new Delay
{
Duration = TimeSpan.FromSeconds(5)
},
new DiceRoll
{
D1 = new OutArgument<int>(env => this.D1.Get(env)),
D2 = new OutArgument<int>(env => this.D2.Get(env))
}
}
};
}
}
AutoResetEvent syncEvent = new AutoResetEvent(false);
WorkflowInvoker invoker = new WorkflowInvoker(new LongRunningDiceRoll());
invoker.InvokeCompleted += delegate(object sender, InvokeCompletedEventArgs args)
{
if (args.Cancelled)
{
Console.WriteLine("Workflow was cancelled.");
}
else if (args.Error != null)
{
Console.WriteLine("Exception: {0}\n{1}",
args.Error.GetType().FullName,
args.Error.Message);
}
else
{
Console.WriteLine("The two dice are {0} and {1}.",
args.Outputs["D1"], args.Outputs["D2"]);
}
syncEvent.Set();
};
invoker.InvokeAsync("InvokeAsync Example");
Console.WriteLine("Waiting for the workflow to complete.");
// Wait for the workflow to complete.
syncEvent.WaitOne();
Console.WriteLine("The workflow is complete.");
설명
워크플로가 완료될 때 알림을 받도록 하려면 .를 처리합니다 InvokeCompleted. 워크플로가 완료되어야 하는 제한 시간 간격을 구성하려면 다음을 수행하는 TimeSpan오버로드 중 InvokeAsync 하나를 사용합니다.
이 메서드는 이벤트 기반 비동기 디자인 패턴을 사용하여 워크플로를 비동기적으로 호출합니다. 자세한 내용은 이벤트 기반 비동기 패턴 개요를 참조하세요.
이 메서드는 메서드의 동기 대응이 throw할 수 있는 모든 비사용 예외를 반환하는 작업에 저장됩니다. 예외가 반환된 작업에 저장되면 태스크가 대기될 때 해당 예외가 throw됩니다. ArgumentException같은 사용 예외는 여전히 동기적으로 던져집니다. 저장된 예외는 .에 의해 Invoke(IDictionary<String,Object>)throw된 예외를 참조하세요.
적용 대상
InvokeAsync(IDictionary<String,Object>, TimeSpan, Object)
지정된 입력 매개 변수, 지정된 IDictionary<TKey,TValue> 제한 시간 간격 및 고유 식별자를 사용하여 워크플로를 비동기적으로 호출합니다.
public:
void InvokeAsync(System::Collections::Generic::IDictionary<System::String ^, System::Object ^> ^ inputs, TimeSpan timeout, System::Object ^ userState);
public void InvokeAsync(System.Collections.Generic.IDictionary<string,object> inputs, TimeSpan timeout, object userState);
member this.InvokeAsync : System.Collections.Generic.IDictionary<string, obj> * TimeSpan * obj -> unit
Public Sub InvokeAsync (inputs As IDictionary(Of String, Object), timeout As TimeSpan, userState As Object)
매개 변수
- inputs
- IDictionary<String,Object>
인수 이름으로 키가 지정된 워크플로에 대한 입력 매개 변수의 사전입니다.
- timeout
- TimeSpan
워크플로가 중단되고 throw되기 전에 완료해야 하는 TimeoutException 간격입니다.
- userState
- Object
이 특정 비동기 호출 작업을 다른 현재 비동기 호출 작업과 구분하는 데 사용되는 사용자 제공 개체입니다.
예제
다음 예제에서는 활동으로 구성된 워크플로를 LongRunningDiceRoll 호출합니다.
LongRunningDiceRoll 작업에는 주사위 롤 작업의 결과를 나타내는 두 개의 출력 인수가 있습니다. 워크플로가 완료되면 처리기에서 InvokeCompleted 검색됩니다.
public sealed class LongRunningDiceRoll : Activity
{
public OutArgument<int> D1 { get; set; }
public OutArgument<int> D2 { get; set; }
public LongRunningDiceRoll()
{
this.Implementation = () => new Sequence
{
Activities =
{
new WriteLine
{
Text = "Rolling the dice for 5 seconds."
},
new Delay
{
Duration = TimeSpan.FromSeconds(5)
},
new DiceRoll
{
D1 = new OutArgument<int>(env => this.D1.Get(env)),
D2 = new OutArgument<int>(env => this.D2.Get(env))
}
}
};
}
}
AutoResetEvent syncEvent = new AutoResetEvent(false);
WorkflowInvoker invoker = new WorkflowInvoker(new LongRunningDiceRoll());
invoker.InvokeCompleted += delegate(object sender, InvokeCompletedEventArgs args)
{
if (args.Cancelled)
{
Console.WriteLine("Workflow was cancelled.");
}
else if (args.Error != null)
{
Console.WriteLine("Exception: {0}\n{1}",
args.Error.GetType().FullName,
args.Error.Message);
}
else
{
Console.WriteLine("The two dice are {0} and {1}.",
args.Outputs["D1"], args.Outputs["D2"]);
}
syncEvent.Set();
};
invoker.InvokeAsync("InvokeAsync Example");
Console.WriteLine("Waiting for the workflow to complete.");
// Wait for the workflow to complete.
syncEvent.WaitOne();
Console.WriteLine("The workflow is complete.");
설명
매개 변수는 userState 현재 작업에 대해 현재 실행 중인 InvokeAsync 모든 작업에서 고유해야 합니다. 고유하지 않으면 userState throw ArgumentException 됩니다.
userState 는 에서 워크플로 InvokeCompleted를 식별하고 .를 사용하여 CancelAsync워크플로를 취소하는 데 사용됩니다.
워크플로가 완료될 때 알림을 받도록 하려면 .를 처리합니다 InvokeCompleted. 워크플로가 지정된 제한 시간 간격 내에 완료되지 않으면 워크플로가 중단되고 throw TimeoutException 됩니다.
메모
TimeoutException 시간 제한 간격이 경과하고 실행 중에 워크플로가 유휴 상태가 되는 경우에만 throw됩니다. 워크플로가 유휴 상태가 되지 않으면 완료하는 데 지정된 시간 제한 간격보다 더 오래 걸리는 워크플로가 성공적으로 완료됩니다.
이 메서드는 이벤트 기반 비동기 디자인 패턴을 사용하여 워크플로를 비동기적으로 호출합니다. 자세한 내용은 이벤트 기반 비동기 패턴 개요를 참조하세요.
적용 대상
InvokeAsync(TimeSpan)
지정된 제한 시간 간격으로 워크플로를 비동기적으로 호출합니다.
public:
void InvokeAsync(TimeSpan timeout);
public void InvokeAsync(TimeSpan timeout);
member this.InvokeAsync : TimeSpan -> unit
Public Sub InvokeAsync (timeout As TimeSpan)
매개 변수
- timeout
- TimeSpan
워크플로가 중단되고 throw되기 전에 완료해야 하는 TimeoutException 간격입니다.
예제
다음 예제에서는 활동으로 구성된 워크플로를 LongRunningDiceRoll 호출합니다.
LongRunningDiceRoll 작업에는 주사위 롤 작업의 결과를 나타내는 두 개의 출력 인수가 있습니다. 워크플로가 완료되면 처리기에서 InvokeCompleted 검색됩니다.
public sealed class LongRunningDiceRoll : Activity
{
public OutArgument<int> D1 { get; set; }
public OutArgument<int> D2 { get; set; }
public LongRunningDiceRoll()
{
this.Implementation = () => new Sequence
{
Activities =
{
new WriteLine
{
Text = "Rolling the dice for 5 seconds."
},
new Delay
{
Duration = TimeSpan.FromSeconds(5)
},
new DiceRoll
{
D1 = new OutArgument<int>(env => this.D1.Get(env)),
D2 = new OutArgument<int>(env => this.D2.Get(env))
}
}
};
}
}
AutoResetEvent syncEvent = new AutoResetEvent(false);
WorkflowInvoker invoker = new WorkflowInvoker(new LongRunningDiceRoll());
invoker.InvokeCompleted += delegate(object sender, InvokeCompletedEventArgs args)
{
if (args.Cancelled)
{
Console.WriteLine("Workflow was cancelled.");
}
else if (args.Error != null)
{
Console.WriteLine("Exception: {0}\n{1}",
args.Error.GetType().FullName,
args.Error.Message);
}
else
{
Console.WriteLine("The two dice are {0} and {1}.",
args.Outputs["D1"], args.Outputs["D2"]);
}
syncEvent.Set();
};
invoker.InvokeAsync("InvokeAsync Example");
Console.WriteLine("Waiting for the workflow to complete.");
// Wait for the workflow to complete.
syncEvent.WaitOne();
Console.WriteLine("The workflow is complete.");
설명
워크플로가 완료될 때 알림을 받도록 하려면 .를 처리합니다 InvokeCompleted. 워크플로가 지정된 제한 시간 간격 내에 완료되지 않으면 워크플로가 중단되고 throw TimeoutException 됩니다.
메모
TimeoutException 시간 제한 간격이 경과하고 실행 중에 워크플로가 유휴 상태가 되는 경우에만 throw됩니다. 워크플로가 유휴 상태가 되지 않으면 완료하는 데 지정된 시간 제한 간격보다 더 오래 걸리는 워크플로가 성공적으로 완료됩니다.
이 메서드는 이벤트 기반 비동기 디자인 패턴을 사용하여 워크플로를 비동기적으로 호출합니다. 자세한 내용은 이벤트 기반 비동기 패턴 개요를 참조하세요.
이 메서드는 메서드의 동기 대응이 throw할 수 있는 모든 비사용 예외를 반환하는 작업에 저장됩니다. 예외가 반환된 작업에 저장되면 태스크가 대기될 때 해당 예외가 throw됩니다. ArgumentException같은 사용 예외는 여전히 동기적으로 던져집니다. 저장된 예외는 .에 의해 Invoke(TimeSpan)throw된 예외를 참조하세요.