Imagine that you have a long task and you can only do one at a time. Usually, to do this, you have to stop doing the rest.
Main() {
DoLaundry()
GoAboutYourDay()
}
DoLaundry() {
}
, , , . - . , , , , , . , , , .
// pseudocode
Main() {
ticket = DoLaundry.BeginDoing(CallMeWhenDone)
GoAboutYourDay()
ticket.WaitUntilDone()
}
CallMeWhenDone(ticket) {
cleanLaundry = DoLaundry.FinishDoing(ticket)
}
.
BeginInvoke. , (), , ( ), (state). IAsyncResult, , , . WaitHandle IAsyncResult .
:. , , IAsyncResult, . IAsyncResult EndInvoke.
EndInvoke: IAsyncResult . , , , .
, , . , , .., "/".
MSDN : http://msdn.microsoft.com/en-us/library/2e08f6yc(VS.71).aspx