I want to convert a (relatively) slow event handler to async to avoid blocking the other event subscribers. In the example below I do not want the other subscribers to the Message event to have to wait.
The only thing I can think of looks like "cheating":
client.Message += async (object sender, MessageEventArgs e) => {
await Task.Run(() => { });
logger.Info("Some info {0}", e.Message);
}
Of course I could wrap the whole logger.Info call in the Task, but I don't see why that is better. I just looks less like cheating.
My only other thought is that the handler should be left synchronous, and the Message event should only be subscribed to when latency is not critical. So I could have a second event that is only used by low latency async subscribers.
I am looking for feedback on the proper coding design here.