Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9125703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:51:52+00:00 2026-06-17T06:51:52+00:00

If I have an async method body like so – public async Task GetSomething()

  • 0

If I have an async method body like so –

public async Task GetSomething() {

    await SendText("hi");
    await SendImage("bla.bmp");

}

How can I get the Task object before it is returned to the user when the await kicks in

ie..

public async Task GetSomething() {

    myTasks.Add(Task.Current);
    await SendText("hi");
    await SendImage("bla.bmp");

    //some processing

}

so that somewhere else I can do

 await Task.WhenAll(myTasks);
 Console.WriteLine("All tasks complete");

This is so that I can wait for all tasks to complete before shutting down

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T06:51:53+00:00Added an answer on June 17, 2026 at 6:51 am

    This is not directly possible as the language does not have a facility to access the “current” task.

    There is a workaround though: Wrap your async method in another method. This other method can get hold of the task once the async method returns (which happens approximately at the first await point).

    In all cases I recommend letting the caller add the async Task to your list, not the async method itself. This is useful even from an encapsulation point of view.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let say I have an async method: public async Task Do() { await Task.Delay(1000);
I have some async method public static Task<JObject> GetUser(NameValueCollection parameters) { return CallMethodApi(users.get, parameters,
I have an async method: public async Task<UserLoginExResult> LoginExAsync(CustomTable exRequest, string language, bool throwEx
In my Windows Store app I have a method public async static Task InitAds()
If I have an async method : public async Task MyMethodAsync() { // [..
If I have a .NET 4.5 asynchronous task method, for example: public async Task<String>
I have the following NUnit test class: [TestFixture] public class Tests { async Task<string>
Say I have an async method which saves to file: async Task SaveToFileAsync() {
We have this method: async Task<int> AccessTheWebAsync() { HttpClient client = new HttpClient(); Task<string>
I have an Async method returning a Task. I also wish to offer a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.