0

I have a sync method as below:

public ActionResult Insert([FromBody] Model model) { }

and I also have an async method:

_myMethodAsync();

My async method returns int. If I do like this I have to edit everything

public async Task<ActionResult> Insert(...){
...
await _myMethodAsync();
...
}

Normally when I add without await I get wrong results.

public ActionResult Insert([FromBody] Model model)
{
    //...
    _myMethodAsync();
    //...
}
2

1 Answer 1

1

Call it with await. The compiler will instruct you on what to do next: change Insert to an async method and change its result type from ActionResult to Task<ActionResult>.

Sign up to request clarification or add additional context in comments.

3 Comments

I can't . because if i do what you say i have to edit everything
@CelalSunnetci: And why does that stop you?
there is an easier option

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.