.NET equilavent to C's backtrace(), or How do I find a calling function?

  • Thread starter Thread starter cmn_
  • Start date Start date
C

cmn_

My problem is this:

I am programming an application in C#.NET / WinForms. It contains a
MonthCalendar, and whenever the DateChanged event is fired, and *only*
when changing the month, the application goes into an infinite loop.
The event procedure is in a seperate thread, although I'd rather not
post it here until asked (there's a *lot* of code there).

On top of this, the event procedure is called from several places in
the code. How would I find which function called the event procedure in
code? If there is no way to find the caller of the function, is there
something like the Backtrace() function in the Standard C Library?
(btw, yes I am a C rather than C# coder...)
 
cmn_ said:
My problem is this:

I am programming an application in C#.NET / WinForms. It contains a
MonthCalendar, and whenever the DateChanged event is fired, and *only*
when changing the month, the application goes into an infinite loop.
The event procedure is in a seperate thread, although I'd rather not
post it here until asked (there's a *lot* of code there).

On top of this, the event procedure is called from several places in
the code. How would I find which function called the event procedure in
code? If there is no way to find the caller of the function, is there
something like the Backtrace() function in the Standard C Library?
(btw, yes I am a C rather than C# coder...)
Exception.StackTrace or Environment.StackTrace

Or count the number of times through the loop and add a condition (if
hitCount > 15 {}) where you can put a debugger breakpoint inside and inspect
callstack and variables using the debugger.
 
cmn_ said:
My problem is this:

I am programming an application in C#.NET / WinForms. It contains a
MonthCalendar, and whenever the DateChanged event is fired, and *only*
when changing the month, the application goes into an infinite loop.
The event procedure is in a seperate thread, although I'd rather not
post it here until asked (there's a *lot* of code there).

On top of this, the event procedure is called from several places in
the code. How would I find which function called the event procedure
in code? If there is no way to find the caller of the function, is
there something like the Backtrace() function in the Standard C
Library? (btw, yes I am a C rather than C# coder...)

FWIW, there's no such function in the standard C library as backtrace -
that's strictly a GNU libc extension.

As Ben already replied, you can get the precise stack trace from
Environment.StackTrace.

-cd
 
Back
Top