I'm just new to this world of asynchronous broadcasting.
Please carry my knowledge.
They say when a method encounters an expectation ... " It reports that you need to run the rest of the method when it is completed, and then returns the async method. " <W> I did not receive this part.
Does this mean that the method still continues to work synchronously and waits until the expected return, and then moves on to the rest of the method?
If not, explain why Task.Runit is necessary to run the method in the background or in fire and forgetting mode . Could I still be reached through waiting, too, right? those.
The method continues to fulfill the remaining statements, without waiting for the return of expectation.
Hope this looks like a background approach. Or right? I'm confused.
If a method is labeled async and is waiting, and it, in turn, asynchronously calls another method at a separate level, which is also labeled async and is waiting.
then how does calling the first method, which is marked as asynchronous and expects from a separate method, say that the name ABC should look like this?
I do not want to comment on this method for async / await. So
Task.Run(() => DoWork());
different from ABC (), not marking it async / wait?
Or is it against the principle of asynchrony?
Here is what I am trying to achieve ...
public IList<CreateCaseOutput> ABC(CreateCaseInput CreateCaseInput,SaveCaseSearchInput SaveCaseSearchInput)
{
CaseSQL.getABCParameters(CreateCaseInput, RequestType, out strSPQuery, out listParam);
var AcctLst = rep.ExecuteStoredProcedure<CreateCaseOutput>(strSPQuery, listParam).ToList();
if (!string.IsNullOrEmpty(AcctLst.ElementAt(0).o_case_seq.ToString()))
{
Task.Run(async () =>
{
await DEF(SaveCaseSearchInput, AcctLst.ElementAt(0).o_case_seq);
}).ConfigureAwait(false);
}
console.writeLine("After Async called");
return AcctLst;
}
public async Task<SaveCaseSearchOutput>> DEF(SaveCaseSearchInput SaveCaseSearchInput,Int64? case_key)
{
CaseSQL.getDEFParameters(SaveCaseSearchInput, case_key, out strSPQuery, out listParam);
var AcctLst = await rep.ExecuteStoredProcedureAsync<SaveCaseSearchOutput>(strSPQuery, listParam);
return AcctLst;
}
DEF, which is asynchronous / waiting, should be called in the background in fire mode and forget about approaching from ABC, and after leaving, I want to continue working with the rest of ABC and run DEF in the background. What is wrong in this fire and forget the approach? If i call
only
DEF(SaveCaseSearchInput, AcctLst.ElementAt(0).o_case_seq);
instead
Task.Run(async () =>
{
await DEF(SaveCaseSearchInput, AcctLst.ElementAt(0).o_case_seq);
}).ConfigureAwait(false);
}
return AcctLst;
then this code works synchronously in the debugger.
- ?