How to implement a notification mechanism in a Windows application?

I have a Windows / WPF application written in C #. These applications connect to a remote database hosted on our public server. The application will be installed on all systems. The user can add values ​​to the database with this application. I need a notification mechanism to send notifications about an entire installed Windows application when someone adds any values ​​to the database.

Please advise me on the best approach to implementing this scenario.

Thanks in advance.

+4
source share
2 answers

You can use the SQL Server query notification feature, which allows you to notify applications when data has changed.

Refer to the links below.

http://support.microsoft.com/kb/555893?wa=wsignin1.0

+1
source

Make a common architecture and interface, so you can replace the main transport.

public interface INotificationService { event EventHandler NewNotification; void SendEvent(string eventDetails); } 

As a very simple example.

The implementation, well, you have several (hundreds) options. You note that events are placed in the database. If you guarantee a unique, increasing integer key, you can query the database from each client for any events> the last event identifier. Do this every 10 seconds or as soon as you can leave. This is a very minor performance hit, but not as effective, but very simple and reliable, and you already have access to the database because you host events there.

Alternatively, you can create a web service or a WCF service. The web service should usually be polled, the WCF service can be configured using duplex messages, so you won’t need to be polled.

Other options include MSMQ or one of the other messaging solutions, RabbitMQ, Tibco, what ever. It all depends on the details.

It is important to make sure that you have this initial interface and code, if your database query is getting too slow and you need to switch to Tibco, this is a very localized simple change.

0
source

All Articles