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

  • SEARCH
  • Home
  • 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 8566201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:36:08+00:00 2026-06-11T17:36:08+00:00

I have this line of code: t.ContinueWith(_ => form.Close(), TaskScheduler.FromCurrentSynchronizationContext()); …about which the compiler

  • 0

I have this line of code:

t.ContinueWith(_ => form.Close(), 
                  TaskScheduler.FromCurrentSynchronizationContext());

…about which the compiler has this to say:

Warning 2 Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the ‘await’ operator to the result of the call.

Now, this wasn’t code that I wrote, but I thought that it’s simply adding a continuation to the end of an existing task. I didn’t think it’s actually running the task (or the continuation). So surely this process of merely modifying the task is a synchronous operation? Why would I have to await it?

  • 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-11T17:36:09+00:00Added an answer on June 11, 2026 at 5:36 pm

    Why would I have to await it?

    You don’t have to await it, that’s why it is a warning, not an error. But, if you’re in an async method and you have a method that returns an awaitable object, most of the time, you shouldn’t ignore it.

    In normal synchronous code, you don’t have to do anything special to wait until a method you called completes, each method call always blocks. But with asynchronous methods, you actually have to await them if you want to wait until they complete. Also, if the asynchronous operation fails and throws an exception, you won’t know about it until you await the result of the method (or get the exception from the result some other way, such as calling Wait() if the awaitable is a Task).

    So, if you ignore a returned awaitable value in an async method, it’s likely that you have a bug in your code, which is what the warning is trying to avoid.

    In your case, ContinueWith() returns a Task, which can be awaited, so the compiler assumes that you should await it. But in this case, you don’t want to wait until the continuation completes and Close() most likely won’t throw an exception. So, in this case, the warning is a false positive, it does not actually indicate a problem in the code.

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

Sidebar

Related Questions

I currently have this line of code which has been working for the past
Say I have this line of code in the view. <?php echo CHtml::activeTextField($model,'start_time'); ?>
I have this line of code which I want to concatenate -or at least
I have this line of code byte[] field1 = (reader.GetSqlBinary(reader.GetOrdinal(Field1)).Value; which is a SqlDataReader
Have have this line of code in my form when I create a new
I have this line of code which rounds my numbers to two decimal places.
I currently have this line of code which I want to work in all
I have this line of code that has no effect on the listBox it
I have this line of code in my JSP. (I'm using struts 1.3) <html:form
Let's say I have this line of code in a program: int * number=0;

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.