threadstatic Questions
5
Solved
How does [ThreadStatic] attribute work? I assumed that the compiler would emit some IL to stuff/retrieve the value in the TLS, but looking at a disassembly it doesn't seem to do it at that level.
...
Solubility asked 8/3, 2011 at 2:34
2
Solved
I'm working on a very large and old code base of a desktop winform application. In this code base there are lots of operations performed in background threads, mainly using BackgroundWorker.
A com...
Georgetta asked 22/3, 2017 at 17:43
2
Solved
Is using ThreadStatic and setting the context every time await completes "an option"? Is there another way?
public async void Test()
{
// This is in Thread 1
Foo foo = new Foo();
Context.contex...
Pisciform asked 9/5, 2014 at 1:28
2
Solved
I've written myself a multi-threaded random generator
public static class MyRandGen
{
private static Random GlobalRandom = new Random();
[ThreadStatic]
private static Random ThreadRandom = new ...
Hampshire asked 6/8, 2013 at 17:3
1
Solved
This question in stackoverflow asks how [ThreadStatic] is implemented:
How does the ThreadStatic attribute work?
Some suggested that it should be viewed as an extension of the Thread object.
I'm n...
Shawnna asked 30/12, 2018 at 13:25
2
Solved
I want to figure out about singleton pattern designs. I want to create seperated instances for per thread from my singleton class. So I provided two designs below.
It is Working
class Program
{
...
Forefend asked 11/11, 2017 at 14:12
1
Solved
Is there a possibility to use thread static like variables within a single request? The current code uses a thread static variable for logging purposes and now we want to use async controller metho...
Ehrenberg asked 28/2, 2017 at 11:6
3
Solved
[ThreadStatic] is defined using attribute while ThreadLocal<T> uses generic.
Why different design solutions were chosen?
What are the advantages and disadvantages of using generic over attr...
Hoplite asked 20/8, 2013 at 11:29
1
Please consider these sceanrios:
An async .ashx handler
A async .asmx web-service method
A sync MVC 5 controller action method
I am trying to figure out a way to set "logical thread" specific d...
Backus asked 15/5, 2014 at 21:24
2
Solved
I was reading through the tips and tricks post and I thought I'd try out some of the C# stuff that I'd never done before. Therefore, the following code serves no actual purpose, but is just a 'test...
Tuff asked 12/6, 2012 at 9:10
1
Solved
I am using a proprietary IoC mechanism in my asp.net mvc3 application (on IIS7) that saves state in [ThreadStatic] fields and therefore relies on an assumption that HttpApplication.BeginRequest, Ht...
Fanfani asked 1/1, 2012 at 21:7
2
Solved
I have a logging framework that I've written that has the ability to track "logging context". It has a pluggable strategy framework, however the one I use most often is a ThreadStatic variant that ...
Vino asked 15/12, 2011 at 23:39
2
I recently read this post about poor performance of fields marked ThreadStatic - they're apparently 60x slower than normal field access. Does .NET 4's ThreadLocal< T > perform any better?
Are t...
Fish asked 30/9, 2010 at 8:56
1
Solved
I was wondering how TransactionScope class works to keep the transaction between different method calls (without the need to pass it as a parameter) and I came to this doubt. I've got two considera...
Laine asked 19/9, 2011 at 2:37
2
Solved
I've written small test program and was surprised why lock {} solution performs faster than lock-free but with [ThreadStatic] attribute over static variable.
[ThreadStatic] snippet:
[ThreadStatic...
Sexennial asked 20/8, 2011 at 12:24
3
Solved
Update: as I should have expected, the community's sound advice in response to this question was to "measure it and see." chibacity posted an answer with some really nice tests that did this for me...
Parisi asked 1/2, 2011 at 16:11
2
Solved
I have a component that needs to store static values fore each thread. It's a general component that can be used in many scenarios and not only in ASP.NET.
I was thinking to use the [ThreadStatic]...
Convergence asked 25/1, 2011 at 8:16
1
Solved
This is not a question of how to automatically call dispose - my problem is the opposite:
I have a thread pool where each thread has a ThreadStatic Graphics (which was created from an Image) to per...
Machicolation asked 11/1, 2011 at 14:57
1
Solved
Is there a way to make newly-spawned threads inherit the values of ThreadStatic state (or something like it) on their parent threads? I would like to use this (or something like it) to implement "d...
Massasoit asked 21/1, 2010 at 1:58
1
© 2022 - 2024 — McMap. All rights reserved.