473,657 Members | 2,505 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Event to receive in multiple objects at the same time - how ?

Tom
Dear experts,

this time my problem is, that I will have objects of 3 different
classes, which all should receive their events without knowing each
other.

In real life the following happens:

I have three fingerprints which are waiting for a finger to be put on
sensor.
As soon as the first fingerprint reckognizes a finger, all the others
should be shutten down.

In code the following happens:

scannerX x = new scannerX();
//Start the wait for finger proc in a thread
x.IsFingerPrese nt();

scannerY y = new scannerY();
//Start the wait for finger proc in a thread
y.IsFingerPrese nt();

scannerZ z = new scannerZ();
//Start the wait for finger proc in a thread
z.IsFingerPrese nt();

//IsFingerPresent does the following:
// System.Threadin g.Thread t = null;
// t = new Thread(new ThreadStart(thi s.ScanImage))
// t.Start();

// ScanImage waits for some things to happen and if a finger is
detected,
// it raises an eventproc.

The concrete problem now is:

I can not add an eventhandler of y (scannerY) to z (scannerZ) because
z does not even know that y exists (there is no reference to y).

Is there a way to do something like a global/static eventhandler
which could be used by all objects in my application and could be
raised from anywhere out of my app ?

Thanks for any help !!

Greets

Tom
Nov 16 '05 #1
3 1733
If all the scanner classes look and act the same, why not have a base class, called scanner, derive each scanner from the base class, then call base class event handler, or function.
If thats possible =). (My visual studio is down at the moment)

Good luck.
Steve.

--
Message posted via http://www.dotnetmonster.com
Nov 16 '05 #2
Tom,

Why not have a manager object that the scanners register with? This
object would handle the coordination of shutting down the other scanners
when one detects a fingerprint, or something of that nature. It would most
likely be a singleton or static.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Tom" <ts@ck-de.net> wrote in message
news:2f******** *************** **@posting.goog le.com...
Dear experts,

this time my problem is, that I will have objects of 3 different
classes, which all should receive their events without knowing each
other.

In real life the following happens:

I have three fingerprints which are waiting for a finger to be put on
sensor.
As soon as the first fingerprint reckognizes a finger, all the others
should be shutten down.

In code the following happens:

scannerX x = new scannerX();
//Start the wait for finger proc in a thread
x.IsFingerPrese nt();

scannerY y = new scannerY();
//Start the wait for finger proc in a thread
y.IsFingerPrese nt();

scannerZ z = new scannerZ();
//Start the wait for finger proc in a thread
z.IsFingerPrese nt();

//IsFingerPresent does the following:
// System.Threadin g.Thread t = null;
// t = new Thread(new ThreadStart(thi s.ScanImage))
// t.Start();

// ScanImage waits for some things to happen and if a finger is
detected,
// it raises an eventproc.

The concrete problem now is:

I can not add an eventhandler of y (scannerY) to z (scannerZ) because
z does not even know that y exists (there is no reference to y).

Is there a way to do something like a global/static eventhandler
which could be used by all objects in my application and could be
raised from anywhere out of my app ?

Thanks for any help !!

Greets

Tom

Nov 16 '05 #3
I'd probably do what Nick suggested, which is have a manager object
orchestrate the shutting down of scanners.

but an alternative would be to have a static event define for scanner that
every scanner will link up to in the instance constructor. the first scanner
recognizes a finger will fire that event to initiate the shutdown of other
scanners. two things to look out for, make sure static event is thread safe
and that scanner should implement the Dispose pattern to unhook itself.
otherwise, all scanners will live as long as the AppDomain once constructed
which is probably a bad thing.

"Tom" wrote:
Dear experts,

this time my problem is, that I will have objects of 3 different
classes, which all should receive their events without knowing each
other.

In real life the following happens:

I have three fingerprints which are waiting for a finger to be put on
sensor.
As soon as the first fingerprint reckognizes a finger, all the others
should be shutten down.

In code the following happens:

scannerX x = new scannerX();
//Start the wait for finger proc in a thread
x.IsFingerPrese nt();

scannerY y = new scannerY();
//Start the wait for finger proc in a thread
y.IsFingerPrese nt();

scannerZ z = new scannerZ();
//Start the wait for finger proc in a thread
z.IsFingerPrese nt();

//IsFingerPresent does the following:
// System.Threadin g.Thread t = null;
// t = new Thread(new ThreadStart(thi s.ScanImage))
// t.Start();

// ScanImage waits for some things to happen and if a finger is
detected,
// it raises an eventproc.

The concrete problem now is:

I can not add an eventhandler of y (scannerY) to z (scannerZ) because
z does not even know that y exists (there is no reference to y).

Is there a way to do something like a global/static eventhandler
which could be used by all objects in my application and could be
raised from anywhere out of my app ?

Thanks for any help !!

Greets

Tom

Nov 16 '05 #4

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

Similar topics

10
3581
by: tony kulik | last post by:
This code works fine in ie and opera but not at all in Mozilla. Anybody got a clue as to how to get it right? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <script language="JavaScript" type="text/javascript"> function show(that) { if (box.style.visibility=='hidden') { that.style.visibility = 'visible'}; }
18
2877
by: Christopher W. Douglas | last post by:
I am writing a VB.NET application in Visual Studio 2003. I have written a method that handles several events, such as closing a form and changing the visible status of a form. I have some code that applies to all these events, but I need to have specific code execute when the form closes. The properties for this method are sender (the originator) and e (event arguments). I know how to get typeof (sender) to determine what form or...
21
18711
by: Alo Sarv | last post by:
Hi From what I have understood from various posts in this newsgroup, writing event loops pretty much comes down to this: while (true) { handleEvents(); sleep(1); // or _sleep() or nanosleep(), depending on platform }
1
2535
by: emma middlebrook | last post by:
Hi I want to find out what objects are due to receive an event i.e. those that have added themselves as an event handler via +=. Yes, it's a little pointless perhaps (or can anyone give some good uses for this?!!). How do I do this for an event on a class I implement? Also, how may I do this for an event in the .Net framework e.g. a control?
1
3425
by: Daniel Bass | last post by:
hey guys. overview --------- I'm designing a messaging system that works on the principle of late binding to the I/O objects, depending on the .Net class libraries present in the local folder. I may have an output File.DLL, and ODBC.DLL, that instantiate an abstract parent to stream data i receive... an input .DLL allows data to be streamed
7
2861
by: copx | last post by:
How do you implement an event queue in C? The problem I had is that events needed pointers to the objects they affect and I do not know any way to check if pointers are actually valid in C. The main issue is that the objects an event data structure points two might be removed before the event is executed. The only solution I came up with was scanning the entire queue each time an object was destroyed to remove all references to it. That was...
4
2994
by: Academic | last post by:
Does it make sense to put this If e.Cancel Then Exit Sub at the beginning of form closing events so if the user cancels the app's exiting in one Closing routine he will not be asked again by another when its form Closing routine is run? I guess what I'm asking is will that work. If one form sets e.cancelled to true will e.cancel be true when the next form receives a closing event?
31
2575
by: Scott M. | last post by:
Am I correct in thinking that because C# doesn't have the "Handles" keyword that VB .NET does, we have to register event delegates manually in C#, whereas in VB .NET using "Handles" takes care of registering the event delegate for us behind the scenes? In other words, *if* C# did have a "Handles"-type keyword, would we still need to register an event delegate?
27
2112
by: cmdolcet69 | last post by:
Can anyone tell me if its possible to do multiple event args in vb.net?
0
8420
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8324
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8842
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8740
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8516
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7353
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2743
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.