Questions tagged [callcontext]
15 questions
37
votes
2 answers
.NET Core equivalent of CallContext.LogicalGet/SetData
I am trying to move into .net core an existing .net application that is using CallContext.LogicalGet/SetData.
When a web request hits the application I save a CorrelationId in the CallContext and whenever I need to log something later down the…

Gradinariu Cezar
- 553
- 1
- 5
- 12
4
votes
2 answers
Disposing thread static variable
I have a ThreadStatic member in a static class. The static class is used in a multi threaded environment. I want to make sure that when a thread is returned to threadpool (or re-used), the member is disposed (or re-initialized), so any subsequent…

Tanzeel
- 51
- 4
3
votes
0 answers
CallContext value set in web api action filter does not flow to Controller action
I have an asp.net web api where we are starting a transaction using TransactionScope (only for POST,PUT and DELETE but not for GET) in OnActionExecuting of a global action filter and then completing or rolling it back in OnActionExecuted.
Recently…

Jags
- 772
- 7
- 17
3
votes
1 answer
CallContext is carrying foreward the previous data which was set
I have this condition where I see that the thread's CallContext is carrying foreward the data in consequent calls.
Consider I have a simple API which when queired, will set one data entry into CallContext using :
// entry to the API execution…

Nameless
- 1,026
- 15
- 28
1
vote
0 answers
AsyncLocal & CallContext - How can I achieve both async *and* remoting logical context guarantees?
I'm attempting to develop a library that implements the loosely-defined Ambient Context pattern. I need to consider both a high-degree of parallelism and remoting (.NET Framework 4.6.2). It seems I have 2 options available: AsyncLocal and…

Matt
- 1,674
- 2
- 16
- 34
1
vote
2 answers
Using the CallContext to store the HttpContext for WCF
I currently have a WCF service used to perform some database queries and send a mail. Long story short, both methods are async use HttpContext.Current somewhere in their implementation.
My initial problem is that after the first await,…

ssougnez
- 5,315
- 11
- 46
- 79
1
vote
1 answer
Why AsyncLocal is different from CallContext
Running the bellow code you can see that there is a different between CallContext and AsyncLocal.
using System;
using System.Runtime.Remoting.Messaging;
using System.Threading;
namespace AsyncLocalIsDifferentThanCallContext
{
class Program
…

Fitzchak Yitzchaki
- 9,095
- 12
- 56
- 96
0
votes
0 answers
Can I create a new AppDomain without remoting call context?
We have some code that creates a new appdomain to perform a untrusted calculation.
We are hitting a serialization exception creating the new appdomain because of some data that is stored in:
System.Runtime.Remoting.Messaging.CallContext
We were able…

Derek
- 7,615
- 5
- 33
- 58
0
votes
0 answers
Why does CallContext.LogicalGetData not return my object?
I want to access the IOwinContext through a provider I can inject into my controllers/services. To achieve that I am using a middleware that sets the context into the CallContext as:
public static IAppBuilder UseOwinContextInitializer(this…

Jules
- 7,148
- 6
- 26
- 50
0
votes
2 answers
Data flow between Parent and child threads in Dotnetcore
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.…

Durai
- 87
- 12
0
votes
0 answers
C# CallContext class can store 2 keys?
Existing code:
public abstract class MyProjectDb: DB
{
public static DB ActualDb
{
get
{
DB d1 = CallContext.GetData("_d1_") as DB;
if (d1 == null)
{
d1 = new…

thepasserby
- 5
- 2
0
votes
2 answers
How to prevent task from inheriting parent task Logical Call context
I am trying to use AsyncLocal as a replacement for Thread local storage when using Task.Run() and Async methods.
The problem I have is that i need the code below to print
from t1 t1
from t1 t1
from t2 t2
from t2 t2
This would be the behavior if…

skyde
- 2,816
- 4
- 34
- 53
0
votes
1 answer
Do I need to cleanup NLog MDLC myself?
I am using NLog 4.5.10 with C# 4.7.1 inside a REST server.
There I am using the method MappedDiagnosticsLogicalContext.Set(item, value) to add some parameters of the request to my log message.
The question now: Do I have to clean them up manually or…

Daniel P.
- 43
- 4
0
votes
1 answer
Create AppDomain without/empty CallContext
Inside an ASP.NET application, I want to create an AppDomain in which untrusted code will be running. However when initializing and unwrapping my assembly loader, an exception is thrown about a type that I'm not passing in. It's the current user…

Bouke
- 11,768
- 7
- 68
- 102
0
votes
1 answer
.net core AsyncLocal loses context with System.Reactive
I want to use AsyncLocal to pass information through async workflows for tracing purpose. Now i faced a problem with RX.
Thios is my test code:
using System;
using System.Reactive.Linq;
using System.Reactive.Subjects;
using System.Threading;
using…

JayJay424
- 1
- 1