Mediatr: Question: Name convention for async methods.

Created on 1 Jan 2020  路  3Comments  路  Source: jbogard/MediatR

Why methods return Task or Task\ do not end with the suffix "Async"? Msdn say "_The name of an async method, by convention, ends with an "Async" suffix._" For example in interfaces IMediator, IRequestHandler, INotificationHandler et褋 .

Most helpful comment

All 3 comments

I've seen Async suffixes within libraries that offer both sync and async versions of a given operation. EF/EF Core is one such example. For a library such as this, IMO such a convention is redundant.

Yes, but when we call the Send method, we usually want to wait for the completion of the corresponding handler. To do this, we use the keyword await. In addition, the handler itself often contains asynchronous operations. Therefore, the suffix "Async" is appropriate.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mdmoura picture mdmoura  路  4Comments

tool-cmd picture tool-cmd  路  4Comments

sq735 picture sq735  路  7Comments

qazq picture qazq  路  3Comments

FuncLun picture FuncLun  路  5Comments