I am trying to maintain data between parent and its child threads in .NET Core web applications.
where I need to store the web application name and web request URL of the Parent thread and needs to use it when its child thread starts its execution. Even if the Parent thread completes its execution before its child thread starts its execution i need to maintain the parent data. I have tried Execution Context, Sync Local, Thread Local/static to maintain data between parent and child threads, and did not help.
- Can anyone suggest the way/ways to maintain data between parent and its child threads in .NET Core.
- In .NET Framework I found
CallContext.LogicalSetData()andCallContext.LogicalGetData(), but .NET Core doesn't supportCall Context.
Could anyone suggest us an Alternative approach for this in .Net Core?
System.Runtime.Remoting.Messaging ==> class CallContext
Thanks in Advance.
Your question is more of an opinion/approach rather than a technical problem. Here is the best I can answer it.
Inter-Process Communication (IPC) is very tricky.
The idea is that you have a shared object that works in uni/bi-direction.
Consider
producer/consumerpattern. ConsiderRediscache.Strong statement alert. Read/apply at your own risk/understanding
async/await.ConcurrentQueue<T>if that helps solve IPC. They all translate to message-broker pattern.TaskCompletionSourceis another nice strategy to facilitate IPC.