I have a hub class that has a long way to go, I have to show progress bar while working .
I read and I think it is possible to use an IP्रेस interface in the IIPRI interface to send long-running operation status.
I will write a method like this:
Public ASCs work & lt; String & gt; GetServerTime (Ignorant and lieutenant; et; g; prog) {wait function.Run ((=) for {{int i = 0; i & lt; 10; i ++} {program report (i * 10); System Threading. Sleep (200);}}); Return Date Time.Now To string (); }
And I try to apply the method like this:
var appHub = $ .connection.appHub; $ .connection.hub.start (); AppHub.server.getServerTime () .done (function (time) {warning (time);});
But I do not know how I can get a progress report.
You, like:
var appHub = $ .connection AppHub; $ .connection.hub.start () Done (function () {appHub.server.getServerTime (). Progress (function) {alert (update);}) .done (function (time) {warning (time);});});
On the one hand, there is no point in using Task.Run
on the CPU-bound code on the server side. Your server-side code can be as easy as:
public string GetServerTime (IPRGTTIT; GP; contract) {for (int i = 0; i & lt; 10; i + +) {Paper. Report (I * 10); System.Threading.Thread.Sleep (200); } Return Date Time.Now Toasting (); }
Your server-side methods should only be async
, if they have the right asynchronous function (usually I / O-forced operation). As a general rule,
Comments
Post a Comment