Хелпикс

Главная

Контакты

Случайная статья





Asynchronous Programming Model



Asynchronous Programming Model

Misnichenko Vladyslav

Faculty of Thermal Engineering, NTUU “KPI”

The classes, which have built-in support for asynchronous model, have a pair of asynchronous methods for each of the synchronous method. These techniques begin with the words Begin and End. For example, if we want to use the asynchronous version Read method Class System. IO. Stream, we need to use the methods and BeginRead EndRead the same class.

 To use the built-in support for asynchronous programming model, you need to call the appropriate method and choose the model BeginOperation end the call. Calling BeginOperation returns an interface IAsyncResult, which measures the state of the asynchronous operation.

 

EndOperation

 

 EndOperation method used for the completion of the asynchronous call when the main thread needs to do a lot of calculations, which do not depend on the results of an asynchronous method call. Once the main work is done and the results of the application needs to perform an asynchronous method for further action, the method EndOperation. At the same time the main thread will be suspended until the completion of an asynchronous method.

 

Callback

 

 The method of completing asynchronous call Callback used in cases when it is necessary to prevent blocking of the main flow. When using the Callback method EndOperation we are launching in the body of the method, which is called at the end of the method, working in parallel flow. The signature of the called method must match the signature of the delegate AsyncCallback.

 

AsyncResult

 

Class AsyncResult used in conjunction with asynchronous method calls with the help of the delegates.. IAsyncResult, returned from the delegate method BeginInvoke, can lead to AsyncResult. AsyncResult tends AsyncDelegate, containing a delegate object to which the asynchronous call was sent.

 

References:

1. https: //msdn. microsoft. com/ru-ru/library/ms228963(v=vs. 110). aspx



  

© helpiks.su При использовании или копировании материалов прямая ссылка на сайт обязательна.