Reputation: 123
Is there any chance to avoid waiting? What we want for example:
async Task SomeTask()
{
await ChildTask();
//Then something we want to be done without waiting till "Child Task" finished
OtherWork();
}
async Task ChildTask()
{
//some hard work
}
Upvotes: 5
Views: 9855
Reputation: 38087
Capture the Task
and then await it after OtherWork
is done:
async Task SomeTask()
{
var childTask = ChildTask();
//Then something we want to be done without waiting till "Child Task" finished
OtherWork();
await childTask;
}
Upvotes: 8
Reputation: 64943
You're not forced to await an asynchronous Task
. If you don't await
it, it's because you don't care if it finishes successfully or not (fire and forget approach).
If you do so, you shouldn't use the async
keyword in your method/delegate signatures.
Upvotes: 6