Following is logger call, which is Blocking:
public static void Info(Category category, SubLevel subLevel, object message)
{
CommonLogger?.Info($"{category}, {(int) subLevel}, {message}");
}
I want to make it Asynchronous execution, therefore I did the following modification, since as per my understanding having Async-Await for void return method, like current one is not a good strategy:
public static void InfoAsync(Category category, SubLevel subLevel, object message)
{
Task.Run(() => CommonLogger?.Info($"{category}, {(int)subLevel}, {message}"));
}
Code Context -
- Make the logging run Asynchronously
- It is Fire and Forget, main business logic proceed separately
My questions are:
Am I correct in making this change ?
Is there still a better way, to do the same ?