Kiy*_*ynL 3 c# delegates action asynchronous async-await
我真的想知道是否有办法定义动作变量async?或者一些替代方法?
public System.Action myAction;
public async System.Action myAsyncAction;
void Start()
{
// normal action
myAction += () =>
{
Debug.Log("Inject some code in runtime..");
};
// I want something like this that support wait time..
myAsyncAction += () =>
{
await Task.Delay(2000f);
Debug.Log("Inject some code in runtime..");
};
}
Run Code Online (Sandbox Code Playgroud)
我Func<Task>过去用过。例如:
Func<Task> asyncMethod = async () =>
{
await Task.Delay(1000);
Console.WriteLine("done here");
};
await asyncMethod();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
447 次 |
| 最近记录: |