Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upIpcMain : add support for async callbacks #386
Comments
|
The callback is Async. Use with Async-Await is also possible if you execute asynchronous code in the callback. Or did I misunderstand you? |
|
While it is technically possible to use async-await in the callback, if the callback produces an exception then this exception will be completely ignored since the I actually did a little bit of digging and it looks like supporting this wouldn't be such an easy fix, since the Right now I think the only workaround would be to just block on the |
|
I am currently working on version 8.31.1 - Trying a completely different Socket.IO .NET client will be a bit short of time ... I will be the father of my second son in early May and will be somewhat limited .. if necessary someone has try another Socket.IO client from the community time .. |
In most GUI APIs, an unhandled exception in a callback is application fatal. It would be normal for a callback to encapsulate it's errors rather than bubble them up to a framework that can't do anything sensible with them.
A real reason this and other such workarounds that try to force async code to be executed by a sync framework, should be avoided, is deadlock. |
|
I snooped around a little on this. Perhaps looking at this as a replacement would be good? https://github.com/HavenDV/H.Socket.IO/ At the very least, the replies back to the electron main process can use async/await. I'd want to dive into it a bit to see if the callbacks can accept an async method as well. |
Callbacks triggered by the UI are async (with respect to the web UI) but are handled with a non-async C# action:
It is now common for C# controller methods to be async so it would be convenient to support them directly with the following overload i.e.
Bridging the sync -> async boundary, might just mean using
Task.Runbut I don't know whether running it on the threadpool is actually optimal because I assumeOnis already being invoked on it's own thread. By implementing this API, hopefully you are able to make the right choice about how to execute the async method without adding unnecessary overhead.