Async / Await vs TPL vs WCF Service vs Web API: so many options

There is code in my ASP.Net 4 web application that starts the process for a long script. The standard output is read, and the return value is updated in the database. I would like to “run and forget” this bit of code so that my user interface remains responsive and the user does not need to wait for these two operations to complete. The end result of these two operations is not needed by the calling code, so I don’t think I need to “wait” and I don’t need any signs of success or failure.

All the available options scare me. What is the best way to encode this so that these two operations are just sent to their fun path and do their work on their own?

+4
source share
3 answers

Well, the “best way” can be controversial, but I would continue using with TPLsomething like the following:

Task parentTask = Task.Factory.StartNew(() => SomeMethod(someParameter));

Note. If the "long running script" calls the WCF service, the following article on WCF asynchronous programming may be helpful. http://blogs.msdn.com/b/wenlong/archive/2009/02/09/scale-wcf-application-better-with-asynchronous-programming.aspx

+2
source

I think you have mixed terms.

WCF - - , .

, , , , .

- ASP.NET, , TPL, Tasks. async await #, .

TPL , , , .NET.

, , .

+2

" "

" " - ASP.NET.

. (HttpClient .NET UI; AJAX HTML-).

- .

-? , " " , . " " , , , .

, "" . , :

  • (, Azure queue Azure WebJob). - . .
  • Use something like HangFire . This is essentially the same, except that the "queue" is a database, and the backend works with your ASP.NET application, and is not completely independent.
  • Use something like HostingEnvironment.QueueBackgroundWorkItem(.NET 4.5.2) or my AspNetBackgroundTasks (.NET 4.5). This is a much more dangerous option, since there is no reliable storage for operation.
+2
source

Source: https://habr.com/ru/post/1542514/


All Articles