I'm writing a class, that must be added as dll file to any .NET project. I'm stuck in point, where I need to make event to System.Diagnostics.StackTrace "last_method_name_changed".
So I need to find a way to detect changes in StackTrace, or create event that is raised when thread enters or exits a method. Something like:
Public Class DllClass
Public Shared CallerTrace as StackTrace = Nothing
Public Shared New(ByRef NewTrace as StackTrace) 'This is called from form.
'''I know this will make a copy, but I have failed to find a solution.
CallerTrace = NewTrace
End Sub
Public Shared Sub StackTrace_Changed() Handles CallerTrace.Changed
MsgBox(CallerTrace.GetFrame(0).GetMethod.Name)
End Sub
End Class
From the main form this should be called only once:
Dim DllCls as New DllClass(New Diagnostics.StackTrace)
I'll be grateful for any help in making "reference link" or pointer to StackTrace and event that will raise when CallerTrace.GetFrame(0).GetMethod.Name
is changed.