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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:01:45+00:00 2026-05-21T09:01:45+00:00

I’m trying to enhance our server platform with the ability to track some kind

  • 0

I’m trying to enhance our server platform with the ability to track some kind of an ambient context that we define. Every context has at least an ID that may or may not be used by various parts of our platform as functional flow progresses. Within a context, threads may be created (or async invokes, or things like WF which executes on other threads). I’d like for those children threads to be able to participate in the context of the parent at least to get the ContextID.

I imagine something like the following:

using (Context ctx = Context.Create()) {
    Log.Print(Context.Current.ID);
    Task task = Task.Factory.StartNew( () => {
        Log.Print(Context.Current.ID);
        using (Context ctx2 = Context.Current.CreateChild()) {
            Log.Print(Context.Current.ID);
        }
        ...
    }
    ...
    task.Wait();
}

So what should be printing is something like:

“ContextID1”

“ContextID1”

“ContextID1:ContextID2”

The primary purpose to help track log messages across many servers much easier than what we have now. Program and data flows between many (hundreds of) machines and it’s too tedious to track from one to another. Using an ambient correlater will help immensely, the only problem I have right now is I don’t know how child threads can automatically figure out what the context of the parent thread was, let alone access it’s TLS. If I could get just the ManagedThreadID of the parent thead, I can make this whole thing work the way I want.

I realize I can pass the Context in as a start parameter when creating the thread/task, but there’s millions of lines of code in our platform and I cannot just make changes. So to bake it into the core framework and make it perfectly ambient will solve the problem, I do have control over that.

  • 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-05-21T09:01:46+00:00Added an answer on May 21, 2026 at 9:01 am

    I had been designing such a system once and I had to replace all thread-start-related code with custom wrappers that generalized and abstracted out such a context chaining as you want. Unfortunately I’m not aware of a good transparent mechanism that would solve it.

    One of the problems you’ll most likely face is executing code on the thread pool and requiring it to inherit the parent context. Here you need to take the fact of reusing thread pool threads into account. Every work executed on a thread pool thread will have to handle context inheritance gracefully, without influencing any unrelated piece of code that will execute on the same thread in the future.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
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
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace

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.