I'm trying to extend my new WPF Touch Screen Keyboard (DLL) Library, to allow the user to get events from the Touch Screen Object. I'd like to be able to tell the Programmer what Object made the call (or executed the subroutine) that raised the event. Not dissimilar to the Sender as Object event parameters one gets when working with a System Object. Which begs the question, How do I get that information, if I don't ask for it? Is there a way to get this information from some call made in the subroutine about to raise the event? That would be nice, and a time saver for me. Thanks!
views:
33answers:
2
+1
A:
Can you assign a value to the sender object when you are going to raise the event?
RaiseEvent Touched(Me, e)
Miroslav Jeliaskoff
2010-05-27 19:24:52
Ok, I could but... I want to know who called the subroutine. Right now thats what I do. "RaiseEvent OnKeyPush(me,btn)" But I want to get the object that called the subroutine. On many occasions the control calls the subroutine, the user, or another program. I would want to tell where the event came from, who called it. Like: "RaiseEvent OnKeyPush(System.Caller,btn)" or "RaiseEvent OnKeyPush(MySub.CallingObjects.OriginatingCaller,btn)" or something...
Justin
2010-05-27 19:39:20
I've decided, it is better to send my current instance in the event of multiple instances.
Justin
2010-06-04 14:47:04
A:
You can walk the stack be using the StackTrace class. You will not be able to inspect the call stack parameters, but you can inspect the metadata of the parameters (type information).
Brian Gideon
2010-05-27 20:44:29