开发者

what is the best approach for starting a background thread as part of a pollingDuplex scenerio

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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜