1

Short version: Is there a way to somehow save the current call stack and store it for later?

Context: This issue seems like it would be so common that I might just be missing the correct search terms.

A certain class needs to read a variable from a server. I just send the request to the server using an API and at some point in the future a separate thread will get the reply and call some follow up method on the original caller class.

Simple enough, but there might be errors: either the variable I'm trying to get doesn't exist, is an incorrect type or something else. In those cases the best I can output to a debug log can be something like: "Unable to find variable X" and a stack trace of the worker. What I would really like having is a stack trace of the original caller, that I can store somewhere and print out in case there is an error so I can narrow down issues instead of having to hunt down which caller it is.

0

1 Answer 1

4

Environment.StackTrace would give you the current stack trace.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.