Valhalla Legends Forums Archive | .NET Platform | [VB.NET] Last Procedure

AuthorMessageTime
Imperceptus
Not even sure if I title this correctly, so forgive me. 

Is it possible to check what part of my code is calling a procedure?  Example
Sub A1 makes a call to Function C1
Sub B1 makes a call to Function C1

Can i determine in C1 what called it?
July 3, 2007, 10:42 PM
l2k-Shadow
probably not in the language itself, why not just set like a bool in C1 to be true if A1 called it and false if B1 called it?
July 3, 2007, 10:48 PM
K
Yes, using System.Diagnostics.StackTrace,  or you can get the calling assembly with the Assembly class.

http://msdn2.microsoft.com/en-us/library/system.diagnostics.stacktrace(VS.71).aspx
July 3, 2007, 10:52 PM
Imperceptus
that is exactly what I needed. Thank you so much K.

Shadow, That would mean I would have to do that in every procedure that I would check against. and while I guess it would work. I can't vouch that my memory is good enough to do that every time and not make a mess down the road.
July 4, 2007, 12:12 AM

Search