[英]ASP.Net / C# 4.5 — Async Processing — Async Await
I am looking for some direction on what is the best route I should go with this. 我正在寻找什么方向,这是我应该走的最佳路线。 I have posted a few times, going off of some recommended design patterns. 我已经发布了几次,讨论了一些推荐的设计模式。 I have not really received a good direction based on what I am trying to accomplish. 根据我要完成的工作,我还没有真正得到好的指导。 I am new to working with Async Processing, and would appreciate some pointers in the right direction. 我是异步处理新手,并且希望您能向正确的方向提出一些建议。 So far, on one of my previous post I have been called ignorant because I requested code samples. 到目前为止,在我以前的一篇文章中,我被称为无知的,因为我要求提供代码示例。 Please understand I have been reading everything, and trying everything I can find on the internet. 请理解我一直在阅读所有内容,并尝试着可以在互联网上找到的所有内容。 Needless to say there are a LOT of different directions I could go with this, and I am not sure which one is the best. 不用说,我可以采用很多不同的方向,而且我不确定哪个是最好的。
I will explain what I am trying to do, at a high level, and if anyone out there can PLEASE help me by pointing me in the right direction I would appreciate it. 我将在较高的级别上解释我想做的事情,如果有任何人可以向我指出正确的方向来帮助我,我将不胜感激。 Also, if anyone can point me to some code samples, I would love that. 另外,如果有人可以指出一些代码示例,我也很乐意。 I do not mind reading the material, but it makes a lot more sense if I can see code to follow along with what it is saying. 我不介意阅读这些材料,但是如果我能看到遵循其说明的代码,那将变得更加有意义。 Most of the documentation I have found has code samples, or partial code samples, and I have been doing my best to try to use what I have found to work with my specific need. 我发现的大多数文档都有代码示例或部分代码示例,并且我一直在尽力尝试使用发现的功能来满足我的特定需求。 So far, not much luck. 到目前为止,还没有太大的运气。 I will admit, when it comes to ASYNC processing, I guess I am ignorant. 我承认,当涉及到ASYNC处理时,我想我很无知。 :) :)
Anyway, here is what I am trying to accomplish. 无论如何,这就是我要完成的工作。 I am leaving out any specific technology that I may consider using to avoid the debate as to if what I am posting is out of date, or behind the times. 我遗漏了我可能考虑使用的任何特定技术,以避免争论我发布的内容是否过时或落后于时代。 I am looking for a point in the right direction, and I am open to whatever at this point. 我正在寻找一个朝着正确方向发展的观点,并且我对此开放。 I just need to get this working. 我只需要使这个工作。
If anyone can kindly point me in the right direction I will be very thankful. 如果有人能指出我正确的方向,我将非常感激。 I do not mind doing the leg work and reading a mountain of documentation. 我不介意进行腿部工作和阅读大量文档。 I just need to be able to know what I am looking at will provide me with the above functionality. 我只需要能够知道我正在寻找的内容即可为我提供上述功能。 Like I said earlier, ignorance or not, if I can get some sample working code (not asking anyone to code this for me, just some code I can step through and help to understand what is happening) it would help a lot. 就像我之前说的,不管是否了解,如果我可以获得一些示例工作代码(不要求任何人为我编写代码,只需我可以逐步通过一些代码来帮助理解正在发生的事情),它将大有帮助。
Thanks you in advance for your time and consideration. 预先感谢您的时间和考虑。
Since you want some operation to happen at the server side along with the UI responding and showing progress. 因为您希望在服务器端进行一些操作以及UI响应并显示进度。 Showing progress of the event. 显示事件的进度。 I would suggest using Signalr.Net. 我建议使用Signalr.Net。
http://signalr.net/ http://signalr.net/
http://www.asp.net/signalr/overview/getting-started/tutorial-getting-started-with-signalr http://www.asp.net/signalr/overview/getting-started/tutorial-getting-started-with-signalr
This is a realtime web api and with this you can create a hub which has functions say "ProcessReport" and "cancelProcessing" you can call this from javascript while connection is open on click of the button and show the progress popup with a cancel button. 这是一个实时的Web api,您可以使用它创建一个具有“ ProcessReport”和“ cancelProcessing”功能的集线器,在单击该按钮时打开连接时可以从javascript调用它,并显示带有取消按钮的进度弹出窗口。 Have a client event registered with the hub in js say "updatestatus" which can be called from the server to close the popup and eventually close the signalr connection, once the operation is finished. 在操作完成后,在js中用集线器注册一个客户端事件,说“ updatestatus”,可以从服务器调用该事件以关闭弹出窗口并最终关闭信号器连接。 And similarly in the popup cancel click you can again call the hub function cancelProcessing and perform your cancellation and call back with updateStatus. 同样,在弹出的取消单击中,您可以再次调用集线器功能cancelProcessing并执行取消操作,并使用updateStatus进行回调。
Hope this helps. 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.