您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
27 行
415 B
27 行
415 B
using System;
|
|
using System.Collections;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Test.Tools
|
|
{
|
|
public class AsyncTestHelper
|
|
{
|
|
public static IEnumerator Await(Task task)
|
|
{
|
|
while (!task.IsCompleted)
|
|
{
|
|
yield return null;
|
|
}
|
|
|
|
if (task.IsFaulted)
|
|
{
|
|
throw task.Exception;
|
|
}
|
|
}
|
|
|
|
public static IEnumerator Await(Func<Task> taskDelegate)
|
|
{
|
|
return Await(taskDelegate.Invoke());
|
|
}
|
|
}
|
|
}
|