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 7884067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:42:01+00:00 2026-06-03T04:42:01+00:00

I’m trying to understand the purpose of TaskCompletionSource and its relation to async/threadless work.

  • 0

I’m trying to understand the purpose of TaskCompletionSource and its relation to async/threadless work. I think I have the general idea but I want to make sure my understanding is correct.

I first started looking into the Task Parallel Library (TPL) to figure out if there was a good way to create your own threadless/async work (say you’re trying to improve scalability of your ASP.NET site) plus understanding of the TPL looks like it will be very important in the future (async/await). Which led me to the TaskCompletionSource.

From my understanding it looks like adding TaskCompletionSource to a one of your classes doesn’t really do much in as making your coding async; if you’re still executing sync code then the call to your code will block. I think this is even true of microsoft APIs. For example, say in DownloadStringTaskAsync off of WebClient class, any setup / sync code they are doing initially will block. The code you’re executing has to run on some thread, either the current thread or you will have to spin off a new one.

So you use TaskCompletionSource in your own code when you’re calling other async calls from Microsoft so the client of your classes doesn’t have to create a new thread for your class to not block.

Not sure how Microsoft does their async APIs internally. For example, there is a new async method off of the SqlDataReader for .Net 4.5. I know there is IO Completion Ports. I think it’s a lower level abstraction (C++?) that probably most C# developers won’t use. Not sure if IO completion Ports will work for Database or network calls (HTTP) or if its just used for file IO.

So the question is, am I correct in my understanding correct? Are there certain things I’ve represented incorrectly?

  • 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-03T04:42:03+00:00Added an answer on June 3, 2026 at 4:42 am

    TaskCompletionSource is used to create Task objects that don’t execute code.

    They’re used quite a bit by Microsoft’s new async APIs – any time there’s I/O-based asynchronous operations (or other non-CPU-based asynchronous operations, like a timeout). Also, any async Task method you write will use TCS to complete its returned Task.

    I have a blog post Creating Tasks that discusses different ways to create Task instances. It’s written from an async/await perspective (not a TPL perspective), but it still applies here.

    Also see Stephen Toub’s excellent posts:

    • The Nature of TaskCompletionSource
    • Mechanisms for Creating Tasks
    • await anything; (using TaskCompletionSource to await anything).
    • Using Tasks to implement the APM Pattern (creating Begin/End using TaskCompletionSource).
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I am trying to loop through a bunch of documents I have to put
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
this is what i have right now Drawing an RSS feed into the php,
I am trying to render a haml file in a javascript response like so:

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.