|
|
От: |
ie
|
http://ziez.blogspot.com/ |
| Дата: | 05.12.06 04:20 | ||
| Оценка: | |||
Т.е. если задали callback, то должны вызывать EndInvoke в нем, а если не задали, то можно и в текущем потоке. Вообще говоря это бред. Никаких условий на место вызова EndInvoke от присутствия callback не накладывается. Надо лишь помнить, что вызывать его можно лишь единожды для каждой асинхронной операции. В вопросе EndInvoke в ActionCallback не вызывается, т.е. никаких проблем не возникает.Asynchronous delegates allow you to call a synchronous method in an asynchronous manner. When you call a delegate synchronously, the Invoke method calls the target method directly on the current thread. If the compiler supports asynchronous delegates, it will generate the Invoke method and the BeginInvoke and EndInvoke methods. If the BeginInvoke method is called, the common language runtime (CLR) will queue the request and return immediately to the caller. The target method will be called on a thread from the thread pool. The original thread, which submitted the request, is free to continue executing in parallel with the target method, which is running on a thread pool thread. If a callback method has been specified in the call to the BeginInvoke method, the callback method is called when the target method returns. In the callback method, the EndInvoke method obtains the return value and any in/out parameters. If no callback method is specified when calling BeginInvoke, EndInvoke can be called from the thread that called BeginInvoke.