views:

33

answers:

2

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!

+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
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
I've decided, it is better to send my current instance in the event of multiple instances.
Justin
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
I'll look into it, see what comes of it.
Justin