473,408 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

How getting eventhandler attached to an event?

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)
ca************@gmail.com

May 6 '06 #1
5 1712
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)" <ca************@gmail.com> wrote in message
news:eO**************@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)
ca************@gmail.com

May 7 '06 #2
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)
ca************@gmail.com
"Duane Phillips" <du************@askme.askme> wrote in message
news:wN******************************@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)" <ca************@gmail.com> wrote in message
news:eO**************@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)
ca************@gmail.com


May 7 '06 #3
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:
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)
ca************@gmail.com

May 8 '06 #4

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

May 8 '06 #5
Sorry for the delay in saying thank you to the people that replied me!
Carlo
--
-------------------------------------------
Carlo, MCP (Windows Based Applications)
ca************@gmail.com
"Larry Lard" <la*******@hotmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.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

May 18 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Torben | last post by:
For test purposes I attach an event to a control, say a TextBox TextChanged event. At another time the same event delegate is attached to some other control, maybe a listbox. Same event function...
12
by: aplaxas | last post by:
Hi! "CDemo.Call" eventHandler is added to "button3.click" Event when both button1 and button2 are clicked. However, I want to add "cd.Call" only one time even though I clicked both button1 and...
5
by: Adam Clauss | last post by:
I have a webapp which consists of several different webforms. Basically: (1) view the contents of a database (2) one is to add a new entry (3) confirms the new entry. The third form, upon...
4
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new...
13
by: jac | last post by:
Hae, I have a windows form with a ComboBox an other things. On that combobox I have an eventhandler on de selectedindexchanged. But somewhere in my code want to do excecute the same code that...
4
by: TB | last post by:
Hi All: What would be the right way to get the ID of a server control inside an event for that same server control? For example: I have this textbox called textbox1 which the following...
11
by: mark | last post by:
Right now I have a thread that sleeps for sometime and check if an event has happened and go back to sleep. Now instead I want the thread to sleep until the event has occured process the event and...
6
by: Class | last post by:
Hi all, I create a gridview dynamicly because I don't know the columns in advance. I use the Templatefield to create a linkbutton. Everything fine..I have the postbackurl and it works. But now...
3
by: wolverine | last post by:
Hi, I am injecting a javascript code into html pages and attaching some dom events to some elements via attachEvent (IE only). I just want to know that is there any chance by which my event...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.