I have an async method DoSomething() and inside the DoSomething() I am calling another method "SaveINSQLDB()" as below.
private static async Task Dosomething()
{
my few lines of code....
SaveINSQLDB()... // I don't want wait for its response to execute further
// (fire and forget case).
my few lines of code
}
I can do with any of the below approaches, Please suggest me the optimal one (and please state why?).
Case 1.
Task.Run(() => SaveINSQLDB(arg1, arg2));
I can make SaveINSQLDB() a simple static method.
Case 2.
await Task.Run(async () =>
{
await SaveINSQLDB(arg1, arg2);
});
I can make SaveINSQLDB() an static async method.
In My opinion, Case1 is better.