Select the product you need help with
Asynchronously ????? C# ?????? ?? ??? ???? ?? ??? ???? ???????? ID: 315582 - ?? ???????? ?? ?????? ??? ?? ?? ???? ???? ???? ??. ?? ????? ????????Microsoft .NET Framework asynchronously ?????? ?? ??? ???? ?? ??? ???? ????? ??? ?????? ?? ????????? ???? ?? ??? ?????? ?? ???????? ????? ?? ????????? ??? ?? ???? ????? ???? ?? ??? ?????? ?????? ?????? ?? ???? asynchronously ?????? ?? ??? ????? ???? ??????? (?????????) ?????? ??? ??? ?????? ?? ????????? ???? ?? ??? ??? ??? ?? ???? ????? ??? ?????? ?????? ??? ????? ???? ?? ??? ????????? ???? ?? ?? ??? ???? ?? ???? ??? ?? ?????? ??????? ???? ??? Contrast ??, ?? ?? ??? ?????????? ??? ???? ?? ?? ??????? ???????? ?? ??? ??? ?????????? ??? ?? ??? ?? ???? ????????? ???? ?? ?? Visual C# ?? ????? ?? ??? ???? ?? ??? ???? ????? ??????????????? ???? outlines ???????? ?????????, ??????????, ??????? ?????? ?? ?????? ??? ?? ???? ???:
?????????? ??? ????? ???? ?????????????? ????? ?? ???????????? ?? ????? ???? ??? ??? ?? ???? ?? ????????? ??? ??? ?????? ?????? ?? ?? ???? ???????? ??? ???????????? ???? ????????? ?????? ?? ?????? ?? ?? asynchronously wrapped ?????? ?? ??? ???? ?? ??? ??????? ?????? ????? ??? ?? ??????? ???BeginInvoke(), ??EndInvoke(). The parameter lists of these methods vary depending on the signature of the function that the delegate wraps. Note that the Visual Studio .NET IntelliSense feature does not displayBeginInvoke(), ??EndInvoke(), so you do not see them appear in the function lists as you type.BeginInvoke()is used to initiate the asynchronous call. It has the same parameters as the wrapped function, plus two additional parameters that will be described later in this article.BeginInvoke()returns immediately and does not wait for the asynchronous call to complete.BeginInvoke()???? ?? ??IAsyncResult???????? ??? TheEndInvoke()?????? ?? ??? ?????????? ?? ???????? ?? ??????? ???? ?? ??? ????? ???? ???? ??? ?? ?? ??? ???? ?? ??? ??? ?? ???? ???BeginInvoke(). ??? ?????????? ??? ??? ??, ????? ???? ???EndInvoke()??? ???? ???? ?? ?????? ???????? ??EndInvoke()?????? ????? ???? ?????, ??Ref???????? wrapped ?????? ??, ??IAsyncResult???????? ?????? ???? ??? ??BeginInvoke(). ????? ??? ?? ????????? ?? ?? ?????? ?? ?? ????BeginInvoke(), ??EndInvoke()????:
????????? ?????? ?????? ?? ?? ?? ????????? ???? ?? ??? ???? ??? ??: ????? 1: ??? ??? ???? Synchronously????????? ???? ?? ?? ????? ?? ??? ???? ?? ??? ???? ????LongRunningMethod()synchronously ?? ????? ?? ????MethodDelegate????????? ??? ????? ?? asynchronously ????? ?? ???? ?? contrast ???
????? 2: ??? ??? ???? Asynchronously ?? ????? ??EndInvoke()???????? ?? ??? ?????? ?????? ??? ????? invokes ??? ???? asynchronously. ??? ???? ?? ??? ????? ???? ???? ?? ?? ??? ???????? ??BeginInvoke, do some work on the main thread, and then callEndInvoke(). ?? ???EndInvoke()does not return until the asynchronous call has completed. This call pattern is useful when you want to have the calling thread do work at the same time that the asynchronous call is executing. Having work occur at the same time can improve the performance of many applications. Common tasks to run asynchronously in this way are file or network operations.
Sample 3: Calling A Method Asynchronously And Using A WaitHandle To Wait For The Call To CompleteIn this section, the sample calls the method asynchronously and waits for aWaitHandlebefore it callsEndInvoke(). TheIAsyncResultthat is returned byBeginInvoke()has anAsyncWaitHandle???? This property returns aWaitHandlethat is signaled when the asynchronous call completes. Waiting on aWaitHandleis a common thread synchronization technique. The calling thread waits on theWaitHandleby using theWaitOne()?? ??? ????WaitHandle.WaitOne()blocks until theWaitHandleis signaled. ??WaitOne()returns, you can do some additional work before you callEndInvoke(). As in the previous sample, this technique is useful for executing file or network operations that would otherwise block the calling main thread.
Sample 4: Calling A Method Asynchronously by Using the Polling Call PatternIn this section, the sample polls theIAsyncResultobject to find out when the asynchronous call has completed. TheIAsyncResultobject that is returned byBeginInvoke()has anIsCompletedproperty that returnsTrue?????????? ??? ????? ???? ??? ???? ??? ??? ?? ???? ???EndInvoke(). ?? ??? ???????? ???? ????????? ???? ????? ??? ?? ???? ???? ?????? ??? ?????? ????? ???? ??? ?? ?? ??? ??? ????? ???? ?? ??? ?????? ??? ?? Microsoft Windows ?????????, ?? ?? ?? ?????? ??? Windows ????????? ?? ????? ????? ??? ?????????? ??? ????????? ???? ?? ?? ?????????? ????? ?? ????? ???? ?? ??? ???? ?? ???? ???? ?? ???-??? ?? ???? ????IsCompleted????? ?? ??? ??? ??? ????? ?? ???? ??? ?? ???EndInvoke??IsCompleted???? ??True. ???????EndInvoke()?????????? ???????? ????? ??, ?? ?? ?? ??? ??????? ????????? ???? ??? ??? ?? knows ?? ???????? ????? ???
Sample 5: Executing a Callback When an Asynchronous Method CompletesIn this section, the sample provides a callback delegate to theBeginInvoke()function that the system executes when the asynchronous call completes. The callback callsEndInvoke()and processes the results of the asynchronous call. This call pattern is useful if the thread that initiates the asynchronous call does not need to process the results of the call. The system invokes the callback on a thread other than the initiating thread when the asynchronous call completes.To use this call pattern, you must pass a delegate of typeAsyncCallbackas the second-to-last parameter of theBeginInvoke()?????? ?? ??? ???? ???..BeginInvoke()also has a final parameter of type????????into which you can pass any object. This object is available to your callback function when it is invoked. One important use for this parameter is to pass the delegate that is used to initiate the call. The callback function can then use theEndInvoke()function of that delegate to complete the call. This call pattern is demonstrated below.
??????? ID: 315582 - ????? ???????: 04 ?????? 2010 - ??????: 2.0 ???? ???? ???? ??:
???? ?????? ???????? ??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??. ?????????? ?? ??????? ????????? ??????? ??:315582
(http://support.microsoft.com/kb/315582/en-us/
)
| ???? ??????
|




????? ?? ???? ????








