Question

The client application will register requests to monitor events on the server. The Client's call back is added to a dictionary (and refreshed by the client on a regular interval)

The server will monitor an MSMQ private queue for events, and when an event that a subscriber has registered for occurs the server will call the client(s).

This hinges on starting a background thread that can wait on the MSMQ and then call the registered client apps. What is the best way to start up this background thread? My first through was to simply launch it in the Application_Start event of the global.asax file. This has a number of pitfalls, as discussed in Chris Anderson's answer to this SO question Furthermore, this the pitfall of the thread lingering around on the developer machine after they stop debugging the app.

Perhaps there's a completely different approach that is warranted, such suggestions are also welcome.

Was it helpful?

Solution

Why not start your background thread when the first client registers, and signal it to stop when the last client unregisters or times out?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top