How to choose methods for asynchronous call in C #, how to distribute asynchronous

I have several asynchronous ways to write program questions. I am writing a WCF service using some expensive methods that are good candidates for an asynchronous call. But my implementation questions:

  • If I create an async method in the model, then I need to use the async service method to wait for the model method and change the return type to Task<originalType>. This will destroy the consistency of the API API. What is the right way? Is it better to design the service interface as async Taskreturn methods, even if some methods are not expensive and there is no reason to asynchronize it?
  • As I understand it, only an expensive method should be written as asynchronous, but in this case one half of the program will be synchronous and the other half asynchronous. Right?
+4
source share
3 answers

If I will create an asynchronous method in the model, then I need to use the async label service method so that I can expect the model method and change the return type to "Task". This will destroy the consistency of the api service consortium. What is the right way? Is it better to design a service interface like async Tasks that return methods, even if some methods are not expensive and there is little reason to make it asnyc?

WCF Task<T> WCF, , , 3 (, Sync APM) , .

MSDN:

, , . , - , .

WCF WCF

, , , - . ?

@l3arnon, async api , "" , , . , , , , , async api.

WCF, .

+5

, async-await, "" . async-await, ( -).

, , , . , , : .

, , , , WCF , .

+5
  • , , . . Task IAsyncResult SOAP, , Task . .
  • "", IO-. , . 1 . , , . async .
+2

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


All Articles