Using async,await in old codebase
Currently, I'm implementing a custom control that utilizes an API, so there are some async methods. The problem is that I cannot wrap my head around, how I would use them in this old codebase I'm working on (WinForms, .NET Framework 4.8).
Simplified example:
The user control has this method
I'd need to integrate it here somehow
Here I could change
void
to Task
and put an async
in front of it. That'd work, but this method is used here...
(don't ask about method names and how much they do not make sense)
In the first method, i could theoretically use async and leave void as is, but in the second case, i cannot easily add async to the method, because now it requires a Task<bool> of course. Anybody got an idea?4 Replies
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Thank you. But this article states exactly what I was afraid of either rewriting the entire code or use GetAwaiter, GetResult etc. and pray for no deadlocks
yeah those two are pretty much your options
It's
async
all the way down
Just use the quick fixes to turn all the methods that aren't async into async ones lol
Lastly, async Task Main(string[] args)