Storing an async function as a variable

强颜欢笑 提交于 2020-01-03 05:11:13

问题


I have a question that is similar to this question but that differs in that in my case I am dealing with Asynchronous functions.

So as the question says I want to store a method in a variable (to call it later)

In the case of syncrhonous functions

private delegate void eventmethod();  //(for a function without arguments and return void)

private eventmethod MySavedEvent;

void D()
{
}

MySavedEvent = D;
MySavedEvent();

But what happens if the function is actually

Task<returnType> D();

How can I define the delegate there?

来源:https://stackoverflow.com/questions/52811268/storing-an-async-function-as-a-variable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!