Pattern for long running tasks invoked through ASP.NET

安稳与你 提交于 2019-12-05 15:52:38

I've got a book that covers explicitly how to integrate WF (WorkFlow) and WCF. It's too much to post here, obviously. I think your question deserves a longer answer than can readily be answered fully on this forum, but Microsoft offers some guidance.

And a Google search for "WCF and WF" turns up plenty of results.


I did have an app under development where we used a similar process using MSMQ. The idea was to deliver emergency messages to all of our stores in case of product recalls, or known issues that affect a large number of stores. It was developed and testing OK.

We ended up not using MSMQ because of a business requirement - we needed to know if a message was not received immediately so that we could call the store, rather than just letting the store get it when their PC was able to pick up the message from the queue. However, it did work very well.

The article I linked to above is a good place to start.


Our current design, the one that we went live with, does exactly what you asked about a Windows service.

  • We have a web page to enter messages and pick distribution lists. - these are saved in a database
  • we have a separate Windows service (We call it the AlertSender) that polls the database and checks for new messages.
  • The store level PCs have a Windows service that hosts a WCF client that listens for messages (the AlertListener)
  • When the AlertSender finds messages that need to go out, it sends them to the AlertListener, which is responsible for displaying the message to the stores and playing an alert sound.
  • As the messages are sent, the AlertSender updates the status of the message in the database.
  • As stores receive the message, a co-worker enters their employee # and clicks a button to acknowledge that they've received the message. (Critical business requirement for us because if all stores don't get the message we may need to physically call them to have them remove tainted product from shelves, etc.)
  • Finally, our administrative piece has a report (ASP.NET) tied to an AlertId that shows all of the pending messages, and their status.

You could have the back-end import process write status records to the database as it completes sections of the task, and the web-app could simply poll the database at arbitrary intervals, and update a progress-bar or otherwise tick off tasks as they're completed, whatever is appropriate in the UI.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!