Synchronous and Asynchronous Callbacks

I am confused with some terms when reading MSDN documents and code samples.

What are callbacks in C #? In particular, what are synchronous and asynchronous callbacks?

Please explain this from a layman's point of view.

Also explain the IAsyncCallback interface IAsyncResult. How can we do this? (with a very simple example)

Thanks in advance.

+5
source share
3 answers

The interface IAsyncCallbackdoes not exist, so you cannot implement it.

I suspect you really want to know about the IAsyncResultinterface .

MSDN.


IAsyncResult interface (, - ), , . , ( IsCompleted). WaitHandle ( AsyncWaitHandle), . ( result.AsyncWaitHandle.WaitOne())

IAsyncResult, Begin Whatever. (BeginExecuteReader, BeginGetResponse ). Begin Whatever , (, BeginExecuteReader CommandBehavior), AsyncCallback ( ) . IAsyncResult.

AsyncCallback - , , , . , . AsyncCallback IAsyncResult, Begin Whatever . IAsyncResult ; AsyncCallback, , . ( , , null)

AsyncCallback ( - ) End Whatever, Begin Whatever, . IAsyncResult Begin Whatever AsyncCallback. , ( ), . (, -, , WebRequest.EndGetResponse WebResponse). , End Whatever .


IAsyncResult, , . Begin Whatever End Whatever, . IAsyncResult . .

+13

( ) , , , - .

( ) - , .

, , "", - , .

+4

- , . , () ( ) .

- . , , ( ). Async ( )

IAsyncCallback . (), , . , .

+2

All Articles