Click here to Skip to main content
15,887,776 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey,

I got the following case:

1. Thread T1 is running with some work.
2. Thread T2 is checking if some value is true/false. if it's 'true' - T2 should pause T1 execution and resume it after the value is 'false' again.

This is a trivial question, but ... the thread that I want to pause (T1) - was created from another process and I can not alter it's code. Though I can get it's reference or the ID.

Any thoughts on what could be the best way out?

Thanks!

What I have tried:

Was thinking about AutoResetEvent, but not sure how to use it, when I am not supposed to alter the code of thread I want to stop...
Posted
Updated 30-Jan-17 3:19am

 
Share this answer
 
Take a look at this[^].

One warning though. If the thread you're trying to pause isn't written with pausing it in mind you could cause all kinds of concurrency problems in the other process that you're not going to be able to do anything about.
 
Share this answer
 
This is a bad solution to your problem. Never do it.

What you do is building a switch that allow you to stop a car on instant. whatever is its position or situation, note that you don't know where is the car.
Imagine the car is on left line on freeway or crossing a railroad, what will happen ?

State the problem, may be there is another solution.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900