When the BeginInvoke method of a delegate is called, the
execution of the delegate is in another thread. (I'm not
sure if an entirely new thread is created, or if a "sleeping"
thread is used.)
Now, is there any way to stop this execution?
Suppose there are some really heavy calculations (or whatever)
that needs to be performed every time indata change. Assume
it takes somewhere around 10-60 seconds to do these calculations.
An obvious way to implement this is to call the BeginInvoke of
a delegate (in which all the work is done) and get a call to a
callback when the calculations are finished. (So you e.g. don't
lock the GUI and network communications for the 10-60 seconds.)
However, let's say indata can change before the calculations are
finished, and then you want to stop the first "calculation batch"
and start a second with this new indata.
Is this possible to do? The IAsyncResult returned by BeginInvoke
doesn't seem to have any "Abort" method, but is it possible to
derive the corresponding Thread from the IAsyncResult, and call
the Abort method of this Thread? (Or would such a technique mess
things up, e.g. perhaps kill all the outstanding current and
subsequent executions of calls to BeginInvoke?)
/Gomaw