all groups > dotnet windows forms designtime > may 2006 >
You're in the

dotnet windows forms designtime

group:

How getting eventhandler attached to an event?



How getting eventhandler attached to an event? Carlo (mcp)
5/6/2006 11:19:46 AM
dotnet windows forms designtime: Good morning

I have this lines:

AddHandler MyControl1.Parent.Paint, AddressOf PaintParentHandler
AddHandler MyControl2.Parent.Paint, AddressOf PaintParentHandler
AddHandler MyControl3.Parent.Paint, AddressOf PaintParentHandler
AddHandler MyControl4.Parent.Paint, AddressOf PaintParentHandler
AddHandler MyControl5.Parent.Paint, AddressOf PaintParentHandler

Is there a way for getting (at runtime) the list of eventhandlers attached
to an event? In my case, a reference to PaintParentHandler?

Since MyControl1, MyControl2, MyControl3, MyControl4 and MyControl5 are
inside the SAME parent, I need this in order to avoid multiple (useless)
calls to PaintParentHandler.

Thank you.

C.



-------------------------------------------
Carlo, MCP (Windows Based Applications)
carlodevREMOVE@gmail.com


Re: How getting eventhandler attached to an event? Duane Phillips
5/6/2006 6:48:12 PM
Rather than go through all that, can you use a static or global variable to
lock out successive semi-concurrent attempts?

For example:

"
SUB EVENTHANDLER()
STATIC blnIsRunning as boolean
If blnIsRunning then Return
blnIsRunning = True
'remainder of code execution for this handler
blnIsRunning = False
END SUB
"
- or -

"
PUBLIC blnIsRunning as boolean 'a PRIVATE dimension may be more
appropriate...

SUB EVENTHANDLER()
If blnIsRunning then Return
blnIsRunning = True
'remainder of code execution for this handler
blnIsRunning = False
END SUB
"

Cheers!

~ Duane Phillips

[quoted text, click to view]

Re: How getting eventhandler attached to an event? Carlo (mcp)
5/7/2006 8:39:20 AM
Hi Duane
thank you for your suggestion. Unfortunately, it doen not applies to my
case. I don't need to avoid the concurrent execution of a procedure. I
simply need to have just one procedure attached to an event. What I need, in
other words, is a single call to AddHandler, if a handler is already set.
Thank you.

--


-------------------------------------------
Carlo, MCP (Windows Based Applications)
carlodevREMOVE@gmail.com


[quoted text, click to view]

Re: How getting eventhandler attached to an event? Larry Lard
5/8/2006 3:01:04 AM

[quoted text, click to view]

No. The list of event subscribers is a proivate implementation detail
of the Control. It doens't have to tell you who is subscribed.

[quoted text, click to view]

Rough method:

- keep a list of controls
- for each MyControl
- is MyControl.Parent in the list?
- if it is, then we are already hooked to its paint event, so
do nothing
- if it isn't, then hook to its Paint event, and add it to the
list


--
Larry Lard
Replies to group please
AddThis Social Bookmark Button