J
Jeff Brown
I want to implement the following behavior...
1. I start a subordinate thread running. Suppose it initially runs code
section A.
2. At the end of code section A, before it gets to code section B, the
subthread is suspended (by having it call Wait() on an AutoResetEvent, for
example).
3. While the subthread is suspended, the main thread somehow captures and
preserves the subthread's current "execution state."
4. The event is signaled, and the subthread proceeds on its way. Now it's
running code section B.
5. At the end of code section B, before it gets to code section C, the
subthread is suspended again.
6. Now here's the fun part. While the subthread is suspend, the main thread
somehow reinstates the subthread's execution state, which it preserved in
step 3.
7. The event is signaled and the subthread proceeds on its way. But, now,
it's re-running code section B, as if for the first time!
8. This process could be repeated any number of times, such that the
subthread could run code section B any number of times, each time thinking
that it's the first time.
Back in the old days, I would have done this by preserving and then
reinstating the CPU's program pointer, registers and stack contents.
Is there any way to do this in the .NET world? Thanks for any help.
1. I start a subordinate thread running. Suppose it initially runs code
section A.
2. At the end of code section A, before it gets to code section B, the
subthread is suspended (by having it call Wait() on an AutoResetEvent, for
example).
3. While the subthread is suspended, the main thread somehow captures and
preserves the subthread's current "execution state."
4. The event is signaled, and the subthread proceeds on its way. Now it's
running code section B.
5. At the end of code section B, before it gets to code section C, the
subthread is suspended again.
6. Now here's the fun part. While the subthread is suspend, the main thread
somehow reinstates the subthread's execution state, which it preserved in
step 3.
7. The event is signaled and the subthread proceeds on its way. But, now,
it's re-running code section B, as if for the first time!
8. This process could be repeated any number of times, such that the
subthread could run code section B any number of times, each time thinking
that it's the first time.
Back in the old days, I would have done this by preserving and then
reinstating the CPU's program pointer, registers and stack contents.
Is there any way to do this in the .NET world? Thanks for any help.