-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Description
Curious best practice or pitfalls around wanting to have my event handlers be async:
ICustomerManagementService service;
service.CustomerRegistered += async (info) => await ...
This will require the event definition to support.
Modifying the example on the readme.md:
public class CustomerManagementService : ICustomerManagementService
{
// now it's an async event:
public virtual event Func<CustomerInfo, Task> CustomerRegistered;
public virtual async Task RegisterCustomer(CustomerInfo customerInfo)
{
// ... (register a new customer in the system here)
// Invoke event. But should I await or not?
CustomerRegistered?.Invoke(this, customerInfo);
// OR
await CustomerRegistered?.Invoke(this, customerInfo);
}
}
Does it matter either way?
Metadata
Metadata
Assignees
Labels
No labels