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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:01:02+00:00 2026-06-12T04:01:02+00:00

Trying to use new C# 5 async model it was surprising to me AspNetSynchronizationContext

  • 0

Trying to use new C# 5 async model it was surprising to me AspNetSynchronizationContext is an internal class (as well as AspNetSynchronizationContextBase base). Thus undocumented. But it’s essential to know what it does when utilizing async/await feature within your ASP.NET code. Am I correct that
It does guarantee your continuations will get the same HttpContext.Current as original callers?
It does not guarantee the continuations will execute on the same thread as the callers?

If the latter assumption is not true and I get the original thread can I be sure to get the same thread context in continuations? I mean principal/culture associated with the thread and thread local storage? That’s important because ASP.NET localization relies on thread’s culture and my application relies on .NET role security model (thread’s principal).

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

    Am I correct that It does guarantee your continuations will get the same HttpContext.Current as original callers? It does not guarantee the continuations will execute on the same thread as the callers?

    Yes, HttpContext.Current is preserved, and yes, the continuations may execute on a different thread.

    I mean principal/culture associated with the thread and thread local storage? That’s important because ASP.NET localization relies on thread’s culture and my application relies on .NET role security model (thread’s principal).

    Ordinary thread-local storage is lost. You can mitigate this by using LogicalCallContext (which flows with ExecutionContext), but with async it’s easier to just reference the variables directly.

    Principal is always preserved; to do otherwise would be a security risk. This flows with ExecutionContext.

    I believe that culture flows with AspNetSynchronizationContext, but I haven’t tested this out on .NET 4.5’s new implementation.


    You may find my MSDN article on SynchronizationContext helpful. It’s not official documentation (I don’t work for Microsoft), but at least it’s something. Note that the AspNetSynchronizationContext referenced in that article is now called LegacyAspNetSynchronizationContext in .NET 4.5.

    Another great resource is Stephen Toub’s ExecutionContext vs. SynchronizationContext.

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

Sidebar

Related Questions

I am trying to use new Google Cloud Messaging system but I have some
I am trying to use nunits new way of exception handling but I am
I've been trying to use the new jquery-ui, and all but the resizable function
I'm trying to use new-style properties declaration: class C(object): def __init__(self): self._x = 0
I am trying to work out how to use the new asp.net 4.5 async
I'm trying to use the new async/await feature to asynchronously work with a DB.
I am trying to use the new Eventmanager of the Zend Framework 2. I
I'm trying to use the new OpenCV 2.0 API in MS Visual C++ 2008
I am trying to use the new immutable OptionParser in the Scala scopt 2.0.1
I'm trying to use the new ASP.NET Web API to do the following: 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.