async
/await
gained a lot of popularity in the C# world the past few years. Async functions also tend to spread rapidly within an application: Awaitables need to be awaited, therefore the calling function must be async and is therefore also an awaitable which needs to be awaited,... and so forth.
I'm using a C# library in a C++/Cli project. The library exposes async APIs. The Visual C++ compiler does not support async
/await
. Hence I have no way to await any of the APIs the library gives me.
I have the following options:
- Call the async function and "letting it go": Not an option since I often need the return values to proceed.
- Calling
Wait()
or accessing theResult
property of theTask
/Task<T>
objects the async function returns: Causes the infamous dead-lock of the UI thread.
Is there any way to make this work? I wouldn't mind executing the async APIs synchronously if I have to.