473,569 Members | 2,691 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

publish data change to multiple listeners

More experienced programmers may laugh that I had to struggle with
this, but I post it so that others in my position might benefit.

My application allows the user to have many forms open. Some of the
forms allow data items to be changed which should be reflected on
other forms. I cannot predict which forms will be open nor how many
of them. I just know that every time data item X is changed on forms
1 or 2, every occurrence of X on forms 5 and 6 should instantly
reflect the change.

Access support for custom Events seemed to presume that the listener
form had to instantiate the changer form, in a one-to-one
relationship. I couldn't assume this, and now have something working
that handles an unpredictable number of changers and an unpredictable
number of listeners.

=============== ===============

There is a class module named Publisher. Its entire code follows:

Public Event ComposerChange( )
Public Event CompositionChan ge()

Public Sub PublishComposer Change()
RaiseEvent ComposerChange
End Sub

Public Sub PublishComposit ionChange()
RaiseEvent CompositionChan ge
End Sub

=============== =============== =

There is the following code in another module:

Global objPublisher As Publisher

Public Function EventPublisher( ) As Publisher
If objPublisher Is Nothing Then
Set objPublisher = New Publisher
End If
Set EventPublisher = objPublisher
End Function

=============== =============== =

Each form which changes data has code like the following:

EventPublisher. PublishComposer Change

or

EventPublisher. PublishComposit ionChange

=============== =============== =

Each form which wants to listen for data changes has code like the
following:

Private WithEvents centralPublishe r As Publisher

Private Sub Form_Open(Cance l As Integer)
Set centralPublishe r = EventPublisher( )
End Sub

Private Sub centralPublishe r_ComposerChang e()
Me.ComposerList .Requery
End Sub

=============== =============== =

Almost surprisingly, there seems no limit to the number of forms which
can refer to the single Publisher object and listen to its events.
They all get notified.

More sophisticated applications would pass some information when the
event is raised. My application doesn't need that; simply knowing
that "something" has changed is enough.

Suggestions in this newsgroup are welcome, but I don't visit here very
often, and e-mails are automatically trashed. No warranty is
expressed or implied. And yes, you probably would have figured it out
quicker than I did.

HTH
Oct 17 '08 #1
0 1586

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

Similar topics

7
16507
by: User | last post by:
Hi, A page I have shows a different background colour depending on the hash portion of the url as it is first loaded. For example a link to mysite/mypage#0000FF would result in a page with a blue background. But another link, this one to mysite/mypage#FF0000, would not give me a red background if directed to the window where mypage#0000FF was...
4
3844
by: Thomas Paul Diffenbach | last post by:
Can anyone point me to an open source library of /statically allocated/ data structures? I'm writing some code that would benefit from trees, preferably self balancing, but on an embedded system that doesn't offer dynamic memory allocation (to be clear: no malloc, no realloc), and with rather tight memory constraints. Writing my own...
5
2572
by: NoNickname | last post by:
Basically, how do I know that the release versions of all components are being published? The Build | Configuration Manager is confusing me a little in VS2005. I have three projects in my solution: 1) web service website. 2) SOAP Extension Class Lib that compiles to a dll 3) WinForm application with a proxy to test the web service.
5
2869
by: rogsonl | last post by:
My computer was moved last week, and the company changed the network groups we work on. As a result, one of the main benefits from Whidbey (database connectivity) no longer works. Situation: 1. I open a new project based on a windows form 2. I click on "data" and then "Add New Data Source" then I click on next within the wizard 3. I have 3...
0
2066
by: Kamilche | last post by:
''' event.py An event manager using publish/subscribe, and weakrefs. Any function can publish any event without registering it first, and any object can register interest in any event, even if it doesn't exist yet. The event manager uses weakrefs, so lists of listeners won't stop them
30
3365
by: Charles Law | last post by:
Here's one that should probably have the sub-heading "I'm sure I asked this once before, but ...". Two users are both looking at the same data, from a database. One user changes the data and commits it. How does the other user get the updated view without polling for changes? Is there some sort of callback mechanism that can be set up on...
0
1499
by: Ben K | last post by:
Is it possible to setup multiple SQL Server "listeners" like Oracle's so that I can have N X M mapping between LISTENERs and DB INSTANCEs? What I want is to partition access to one database, say "FinancialDB", through one port; but access to another database, say "HumanResourceDB", through another port. This way, I can setup a firewall...
21
3831
by: Al Christoph | last post by:
I posted this last week end in the MSDN forums. No luck there. Let's see what the experts here have to say:-)))) I have a rather convoluted project. The distributable will come in eight different flavors, each with its main program, libraries, datafiles, doco, etc. Each flavor will also have one or more standalone executables that can be...
3
4353
by: Ludwig Wittgenstein | last post by:
Hello, all. Does anyone know of documentation about implementing a publish- subscribe model between a .NET Web service provide and a Java service consumer? I have this problem I am trying to solve, and would greatly appreciate it if someone can tell me what the best solution would be for it. I have a .NET 2.0 (ASMX) webservice on a...
0
7695
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...
0
7612
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...
0
7922
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. ...
0
8119
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...
1
7668
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...
1
5509
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5218
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
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...
0
936
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.