views:

122

answers:

2

I have a multi-threaded .Net app in which thread-local storage is used to hold a flag of sorts. I have reason to suspect that the flag is being set incorrectly in one of the threads and would like to use the VS debugger to inspect when and where the flag is being set.

Once I have stopped the application at a break point, can I use the immediate window to inspect that thread-local flag?

More specifically, on what thread would the immediate window execute the following command

Thread.GetData(Thread.GetNamedDataSlot(flagName))

Alternatively, can you suggest ways to monitor these flags per thread?

+1  A: 

Try naming all your threads and then say ?Thread.CurrentThread.Name on the console. Or alternatively display the managed thread id.

SDX2000
+1  A: 

Experimenting with

Thread.CurrentThread.ManagedThreadId

suggests that the immediate window does the right thing and executes in the same thread as the code with the breakpoint.

Ed Guiness