Hello @Omkar Pimplekar
Here is one option using ForGet, which requires the following NuGet package.
public static async Task<bool> SomeTask()
{
return await Task.Run(async () =>
{
await Task.Delay(2000);
Console.WriteLine("hello");
return true;
});
}
Usage
Console.WriteLine("Before");
SomeTask().Forget();
Console.WriteLine("After");
Results where hello shows up after "after". Now there is a caveat, if code can fail make sure that the calling method wraps the code in a try/catch and that the calling method is not marked as void else the exception is not bubbled up to the caller.
Before
After
hello