异步控制器(MVC),长时间运行的过程和QUOT;停止" [英] Async Controllers (MVC), long running process with "stops"
问题描述
我感兴趣的是运行一个漫长的过程,我想尽快更新UI的结果开始进来,而不是等待它完成。
I'm interested in running a long process, I want to update the UI as soon as results start coming in and not wait for it to finish.
我会如何呢?我读过有关异步控制器,但他们似乎并没有有任何内置的用于这一目的。
How would I go about this? I've read about Async controllers but they don't seem to have anything built-in for this purpose.
只是将结果保存在应用/ Session对象的结果出来并使用轮询的客户端?我能想到的,可能出错多种方式(如用户关闭网页,以及对象停留在应用程序对象永远 - 需要管理这些到期对象自己,额外的服务器负载进行轮询,等等)。
Just save the results in the Application/Session object as the results come in and use polling from client side? I can think of several ways that could go wrong (like user closes page, and the object stays in Application object forever - need to manage expiration of these object myself, extra server-load for polling, etc).
有什么想法?
感谢您
推荐答案
我是想解决类似的东西(报告从长时间运行的服务器操作返回给客户端的实时进度)近日,它原来的 SignalR 是非常适合这种情况。
I was trying to solve something similar (reporting real-time progress from a long running server operation back to the client) recently and it turned out SignalR is a perfect fit for this situation.
基本上它是一个库包长轮询以及Web套接字,使用(透明)任何可用的服务器和客户端。
Basically it is a library wrapping long-polling and Web Sockets, using (transparently) whatever is available on server and client.
我只有用它很好的经验,到目前为止。
I only have good experience with it so far.
这篇关于异步控制器(MVC),长时间运行的过程和QUOT;停止"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!