|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How getting eventhandler attached to an event?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) carlodevREM***@gmail.com 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 Show quoteHide quote "Carlo (mcp)" <carlodevREM***@gmail.com> wrote in message news:eO7Lp4OcGHA.1856@TK2MSFTNGP03.phx.gbl... > 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) > carlodevREM***@gmail.com > > > 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. -- Show quoteHide quote------------------------------------------- Carlo, MCP (Windows Based Applications) carlodevREM***@gmail.com "Duane Phillips" <duane.phillips@askme.askme> wrote in message news:wNqdnZ1JBoZR3sDZnZ2dnUVZ_vOdnZ2d@giganews.com... > 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 > > "Carlo (mcp)" <carlodevREM***@gmail.com> wrote in message > news:eO7Lp4OcGHA.1856@TK2MSFTNGP03.phx.gbl... >> 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) >> carlodevREM***@gmail.com >> >> >> > > Hello, Carlo,
You might be able to get the information you need by iterating through the collection returned by MyControln.Parent.GetType.GetEvents(). Look for a case where the Name property of the matches "Paint". Cheers, Randy Carlo (mcp) wrote: Show quoteHide quote > 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) > carlodevREM***@gmail.com > > > Carlo (mcp) wrote:
> Good morning No. The list of event subscribers is a proivate implementation detail> > 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? of the Control. It doens't have to tell you who is subscribed. > Rough method:> Since MyControl1, MyControl2, MyControl3, MyControl4 and MyControl5 are > inside the SAME parent, I need this in order to avoid multiple (useless) > calls to PaintParentHandler. - 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 Sorry for the delay in saying thank you to the people that replied me!
Carlo -- Show quoteHide quote------------------------------------------- Carlo, MCP (Windows Based Applications) carlodevREM***@gmail.com "Larry Lard" <larryl***@hotmail.com> wrote in message news:1147082464.234824.128920@g10g2000cwb.googlegroups.com... > > Carlo (mcp) wrote: >> 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? > > No. The list of event subscribers is a proivate implementation detail > of the Control. It doens't have to tell you who is subscribed. > >> >> Since MyControl1, MyControl2, MyControl3, MyControl4 and MyControl5 are >> inside the SAME parent, I need this in order to avoid multiple (useless) >> calls to PaintParentHandler. > > 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 >
Simple word count
single to string problem Error setting CSV to display text Simple TCP communications examples Thread terminating instantly How to move the mouse around in vb.net How do I take a screenshot in VB.net 2005 Move emails (.msg files) between an Outlook inbox and a file direc How to simulate mouse click in vb.net My.Settings object set setting by name? |
|||||||||||||||||||||||