By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,042 Members | 1,047 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,042 IT Pros & Developers. It's quick & easy.

walking the call stack from within a thread. Getting the parent call stack

P: n/a
I am trying to use the StackTrace class to get my current stack trace
for some logging. Everything is working fine, except when I am using
threading (specifically WaitCallBack and ThreadPool.QueueUserWorkItem)

When I try to walk the stack from a location that has been called via
QueueUserWorkItem, the stack stops at the point where the thread was
launched. Is there a way to walk back further into the parent thread's
stack (at the time that my own thread was created, not the current
state)

Thanks, Jason.

Nov 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Every thread maintains it's own call stack. Hence the start of the
QueueUserWorkItem is the first entry into the thread stack. As far as I
know, the parent thread will have a current stack trace which you can get,
but not the stack trace at the time of the thread launch.

One solution is for every thread to preserve the parent stack trace as the
first item it executes and use this information for logging purpose.

Hope this helps
Shuvro

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm.

"Jason Coyne" <ga******@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I am trying to use the StackTrace class to get my current stack trace
for some logging. Everything is working fine, except when I am using
threading (specifically WaitCallBack and ThreadPool.QueueUserWorkItem)

When I try to walk the stack from a location that has been called via
QueueUserWorkItem, the stack stops at the point where the thread was
launched. Is there a way to walk back further into the parent thread's
stack (at the time that my own thread was created, not the current
state)

Thanks, Jason.

Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.