Are async / wait useful for web applications?

I read about Async and Await keywords in C # 5.0, which allow you to perform parallel tasks simultaneously. (this is what I understood).

Is this practice useful for web applications?

Here we have AJAX methods that allow you to perform tasks without blocking the user interface (browser).

Should they be used only for asynchronous web services?

Can you give me an example of why / how to use async / await keywords in web applications? (to take advantage of these features)

+5
source share
2 answers

Perhaps the best example I can think of is calling a series of web service methods from your asynchronous action method. For instance:

, , -: Method1 Method2. 1 , 2 , async .

 using (DataClient proxy = new DataClient())
            {
                Task<Object> data1= proxy.Method1();
                Task<Object> data2 = proxy.Method2();

                await Task.WhenAll(new Task[] { data1, data2 });

               //Completed
           }

MSDN:

AsyncController . , . - . AsyncController - -.

: http://msdn.microsoft.com/en-us/library/ee728598(v=VS.98).aspx

+3

async await , - , , , .

, : ?

, , async invokation, , ... - , , async.

+3

All Articles