Register a new pageasynctask using the async Task method, which takes parameters

I have this method in an asp.net webforms project:

private async Task SomeMethod(int accID){ // }

I want to do this in page_load, but I'm not sure how to handle the parameters.

protected void Page_Load(object sender, EventArgs e)
    {
        RegisterAsyncTask(new PageAsyncTask(SomeMethod(int accID)));

       // etc
}
+4
source share
1 answer

Try the following:

protected void Page_Load(object sender, EventArgs e)
    {
        RegisterAsyncTask(new PageAsyncTask(() => SomeMethod(accID: 1000)));

       // etc
}
+14
source

Source: https://habr.com/ru/post/1533488/


All Articles