473,385 Members | 1,343 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,385 software developers and data experts.

Collection (hashtable) of objects that raise events

Hi All,

I have a class (class 1) that raises a couple of events.

I also have another class (class 2) that contains a hashtable
of objects that are of type class 1.

Is there anyway of trapping the events raised by one
of the objects in the hashtable in class 2 and processing
the event in class 2?

Many thanks,

Jason.
Nov 21 '05 #1
3 1398
Jason,

I don't see the problem as a sample (not a hashtable) roughly typed in this
message

\\\
Public class1
public sub new
dim obj2 as new class2
addhandler obj2.theEvent, AddressOf bla_Event
end sub
public sub bla_Event()
'do what you want
end sub
end class
Public class2
Public sub new
public event theEvent()
public tim as new timer
tim.enabled = true
tim.interval = 1000
addhandler obj2.theEvent, AddressOf bla_Event
end sub
public sub bla_Event
raise theEvent
end sub
////

I hope this helps?

Cor
Nov 21 '05 #2
Jason,

"Jason L James" <ja***@nospam.divemaster.org> schrieb:
I have a class (class 1) that raises a couple of events.

I also have another class (class 2) that contains a hashtable
of objects that are of type class 1.

Is there anyway of trapping the events raised by one
of the objects in the hashtable in class 2 and processing
the event in class 2?


You can add a common handler for 'class1''s event using 'AddHandler' for
each instance of 'class1'. The event handler's 'sender' parameter will
contain a reference to the object that raised the event. 'RemoveHandler'
can be used to remove a handler.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #3
Thanks Guys, I'll give it a go.

Jason.

On Mon, 7 Feb 2005 14:28:03 +0100, "Herfried K. Wagner [MVP]"
<hi***************@gmx.at> wrote:
Jason,

"Jason L James" <ja***@nospam.divemaster.org> schrieb:
I have a class (class 1) that raises a couple of events.

I also have another class (class 2) that contains a hashtable
of objects that are of type class 1.

Is there anyway of trapping the events raised by one
of the objects in the hashtable in class 2 and processing
the event in class 2?


You can add a common handler for 'class1''s event using 'AddHandler' for
each instance of 'class1'. The event handler's 'sender' parameter will
contain a reference to the object that raised the event. 'RemoveHandler'
can be used to remove a handler.


Nov 21 '05 #4

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

Similar topics

2
by: rawCoder | last post by:
Hi, I must be missing something here. All I want is to be able to handle the events of one of my class, objects of which are in a collection. For e.g. I have a class MyClass1 which raises...
10
by: Mart | last post by:
What class does everyone out there use if they want to store a set of values efficiently? In java I use a HashSet, but there is no equivalent in C#. Even worse, the lowest level interface to...
2
by: Maria | last post by:
Hi Guys (and Gals) Bit of a newbie to C# here and I am having a problem which I am coming across. I need to capture when events are raised in child objects within a collection and raise them...
8
by: orekin | last post by:
Hi There I have a huge array of objects being displayed on a UI. These are actually 'jobs' that the users need to deal with before close of business. As the operator deals with a particular...
3
by: Franky | last post by:
IN vb.Net Class clsCommande Inherits CollectionBase and Class clsProduct clsCommand contain a IList of clsProduct
13
by: Scott Meddows | last post by:
I'm writing an NT service to provide security information enterprise wide. I would like to have all of this information cached memory if a previous request loaded it into memory. Then using a...
6
by: Scott M. Lyon | last post by:
As I mentioned in my other post, I'm attempting to, using COM Interop so I can update existing VB6 code to (for several specific functions) return a Hashtable from a .NET library. I've had...
18
by: Larry Herbinaux | last post by:
I'm having issues with garbage collection with my long-standing service process. If you could review and point me in the right direction it would be of great help. If there are any helpful...
5
by: jwilson128 | last post by:
I am looking for some help on the best type of collection to use and/ or best way to implement the collection with the following functionality: I have defined an object to represent an interest...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.