Implementation of IHandle<T> for synchronous handlers
See original GitHub issueIn earlier versions of Caliburn Micro, we used to have separate implementations of IHandle (and IHandleWithTask). However, in 4.x, this seems to be changed and replaced with a single interface.
public interface IHandle<TMessage>
{
Task HandleAsync(TMessage message, CancellationToken cancellationToken);
}
One issue I find with this approach is that in the scenarios when there are no asynchronous calls in the handlers, the naming convention looks out of place with the Async suffix. The code style checkers would show these as warnings as well, leaving a clutter of warnings in the solution.
Wouldn’t it be better to bring back the IHandleWithTask
to separate the different implementations ?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Synchronous implementation of interface that returns Task
So let's suppose that implementation looks like this: public class SimplyAwesome : IAmAwesome { public async Task MakeAwesomeAsync() { // Some ...
Read more >Walkthrough: Creating an Asynchronous HTTP Handler
This walkthrough illustrates how to create an asynchronous HTTP handler. Asynchronous HTTP handlers enable you to start an external process ...
Read more >Code Tip: How to work with asynchronous event handlers in C ...
This post describes how you can add support for asynchronous event handlers when developing class in C#.
Read more >Synchronous and asynchronous requests - Web APIs | MDN
Synchronous requests block the execution of code which causes "freezing" on the screen and an unresponsive user experience. Asynchronous request.
Read more >Asynchronous Handlers • NServiceBus
Handlers and sagas are executed by threads from the thread pool. Depending on the transport implementation the worker thread pool thread or ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I don’t think putting both functions into IHandle is an option because then users are forced to implement one no-op for each handler (unless I misunderstood the suggestion?). To the original point, in scenarios with no asynchronous calls, code style checkers should only show a warning if the async keyword is used. Setting the handler as the following should work fine:
C#8 has support to add default implementations to methods. Updated the IHandle interface to add have default implementation for .net 5, .net 6, and .net core 3.1 #780