Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use Asynchronous delegates on a void return method

i want to make a method async

public static void PrepareData<T>()
{
 // prepare data ....
}

i was trying to do the following

Func method = PrepareData<T>;
method.invoke
...

but it complain Func must specify something e,g Func

so my question is, how to make a void return method asyn??

Thanks.

like image 918
jojo Avatar asked Nov 27 '25 17:11

jojo


1 Answers

You should use Action instead of Func. The Action family is for functions with a void return type, Func is for those that actually return something.

like image 191
Jon Avatar answered Nov 30 '25 07:11

Jon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!