J
Joshua Frank
Hi All,
I'm trying to use this to determine which method called my method. I
have two ways, but neither is quite right:
Method 1:
Sub WhereAreWe()
Dim sf As New System.Diagnostics.StackFrame(1, True)
...
End Sub
But in this code
1 Sub Test()
2 WhereAreWe()
3 WhereAreWe()
4 End Sub
the stack frame is different in each WhereAreWe call, in that the first
time it knows that the caller is on line 2 and the second it knows that
it's on line 3. I can get around this by using StackFrame.GetMethod,
but then I get a different problem:
Method 2:
1 Sub RecursionTest()
2 If ReachedBottom Then Exit Sub
3
4 WhereAreWe()
5 RecursionTest()
6 End Sub
When I do this, the WhereAreWe function has no way of telling where,
exactly, we are, because GetMethod is the same for regardless of how
many frames deep we are in the recursive call stack.
So, is there any way to tell where we are, solving both of these
problems at once? TIA.
Cheers,
Josh
I'm trying to use this to determine which method called my method. I
have two ways, but neither is quite right:
Method 1:
Sub WhereAreWe()
Dim sf As New System.Diagnostics.StackFrame(1, True)
...
End Sub
But in this code
1 Sub Test()
2 WhereAreWe()
3 WhereAreWe()
4 End Sub
the stack frame is different in each WhereAreWe call, in that the first
time it knows that the caller is on line 2 and the second it knows that
it's on line 3. I can get around this by using StackFrame.GetMethod,
but then I get a different problem:
Method 2:
1 Sub RecursionTest()
2 If ReachedBottom Then Exit Sub
3
4 WhereAreWe()
5 RecursionTest()
6 End Sub
When I do this, the WhereAreWe function has no way of telling where,
exactly, we are, because GetMethod is the same for regardless of how
many frames deep we are in the recursive call stack.
So, is there any way to tell where we are, solving both of these
problems at once? TIA.
Cheers,
Josh