Valhalla Legends Archive

Programming => General Programming => .NET Platform => Topic started by: Imperceptus on July 03, 2007, 05:42 PM

Title: [VB.NET] Last Procedure
Post by: Imperceptus on July 03, 2007, 05:42 PM
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?
Title: Re: [VB.NET] Last Procedure
Post by: l2k-Shadow on July 03, 2007, 05:48 PM
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?
Title: Re: [VB.NET] Last Procedure
Post by: K on July 03, 2007, 05:52 PM
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
Title: Re: [VB.NET] Last Procedure
Post by: Imperceptus on July 03, 2007, 07:12 PM
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.