本文整理汇总了C#中Policy.Awaiting方法的典型用法代码示例。如果您正苦于以下问题:C# Policy.Awaiting方法的具体用法?C# Policy.Awaiting怎么用?C# Policy.Awaiting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Policy
的用法示例。
在下文中一共展示了Policy.Awaiting方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Executing_the_synchronous_policies_using_the_asynchronous_execute_and_capture_should_throw_an_invalid_operation_exception
public void Executing_the_synchronous_policies_using_the_asynchronous_execute_and_capture_should_throw_an_invalid_operation_exception(Policy syncPolicy, string description)
{
syncPolicy
.Awaiting(x => x.ExecuteAndCaptureAsync(() => CompletedTask))
.ShouldThrow<InvalidOperationException>()
.WithMessage("Please use the asynchronous RetryAsync, RetryForeverAsync, WaitAndRetryAsync or CircuitBreakerAsync methods when calling the asynchronous Execute method.");
}
示例2: Executing_the_synchronous_policies_using_the_asynchronous_execute_and_capture_should_throw_an_invalid_operation_exception
public void Executing_the_synchronous_policies_using_the_asynchronous_execute_and_capture_should_throw_an_invalid_operation_exception(Policy syncPolicy, string description)
{
syncPolicy
.Awaiting(async x => await x.ExecuteAndCaptureAsync(() => TaskHelper.EmptyTask))
.ShouldThrow<InvalidOperationException>()
.WithMessage("Please use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods.");
}