473,320 Members | 1,950 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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

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
1 4750
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Carlos Ribeiro | last post by:
Hello all, I'm posting this to the list with the intention to form a group of people interested in this type of solution. I'm not going to spam the list with it, unless for occasional and...
39
by: Randell D. | last post by:
Folks, I'm sure this can be done legally, and not thru tricks of the trade - I hope someone can help. I'm writing a 'tool' (a function) which can be used generically in any of my projects. ...
5
by: Adrian | last post by:
Is there a way (understandably non-portable) to get the call stack from within a function? That is, assuming the application has been compiled with symbols, get the list of calling function names...
24
by: ALI-R | last post by:
Hi All, First of all I think this is gonna be one of those threads :-) since I have bunch of questions which make this very controversial:-0) Ok,Let's see: I was reading an article that When...
11
by: Yahoo | last post by:
I have a programming issue where I need to know the whole history of the call stack to ensure it was never within a given method (specifically my own method). I am hooking into the XmlDocument...
3
by: Tommy Vercetti | last post by:
I have a complex threading deadlock scenario that I've been able to reproduce in the debugger. I hit break and look at the call stack which should tell me what I need. Except I only get the very...
10
by: Nak | last post by:
Hi there, After recently coming across issues with implementing a UDP server for interprocess communication; involving file transfer, I have decided to go onto TCP. Now I *have* created a TCP...
5
by: Stephen Barrett | last post by:
I have read many threads related to async fire and forget type calls, but none have addressed my particular problem. I have a webpage that instantiates a BL object and makes a method call. The...
9
by: Jensen Somers | last post by:
Hi, Is it possible to change the stack size of a DLL from within the source code? When using threads you can specify the size of the stack you want the thread to use, but since my application...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.