by the way, earlier I said it is a bug but it might also be considered as a design issue.
here is the problem about the code:
when you call an async method, the process is handled by a worker thread from thread pool. as soon as the process is completed, the worker thread returns to pool and callback method is invoked in the "caller thread"
so if you invoke another async method/delegete within an async method/delegate, here is what happens sometimes:
if the first async method is completed and the worker thread returned to thread pool already when the inner (second) async method is finished, it tries to get first worker thread (for callback method). but by the time then, it might be used for another process since it is a thread pool.
__________________
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it."
|