2 of 2
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Just fire the task without async/await.
private void InitMethod(ServiceControl serviceControl)
{
if (serviceControl != null)
{
Task.Factory.StartNew(() => serviceControl.Execute());
}
}
In a proper F&F task all exception handling (including a final catch, logging, notifications) is done by the task itself, so you don't need exception handling that async/await
provides.
Make the method name reflect what it does. I wouldn't mind a name like FireAndForgetXyz
Gert Arnold
- 2.1k
- 1
- 17
- 26
default