-
-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BackgroundWorker is busy even after IsProcessRunning is false #51
Comments
Hi @Loucool111 I would have to do a real deep dive here to understand why you don't get a change in value, but I expect it is down to the fact that you are essentially absolutely thrashing the main program thread because you are running a constant loop, with no breaks. In general, any kind of loop like this:
Is going to quickly put the CPU to 100%, you don't give it any time to switch to other threads in the process. Running in the debugger means again you are probably artificially slowing things down enough. So even if you use this code, I would at least sleep for 1ms. However, why not do something like this?
You can get |
Yeah no this doesn't work at all... if I call processInterface.StartProcess() and then check "IsProcessRunning" it is false... so it seems you cannot tell when to issue the next processInterface.StartProcess(). You should have used a callback system where you could set a callback function to execute when the process finishes. |
I'm experiencing similar problem. What I also see, that the process starts, but does not seem to be running. I've created following workaraoud: ` public void StartProcess(string name, string args)
|
It seems that the process when exits there is still (buffered?) lines to be sent to the richtextbox, and worker is busy with that. |
Hello,
So basically i'm looping over some array and for each item I want to start a new process and when it ends, carry on with the next one...
Here is the code (I'm calling this from another thread) the view.console object is ConsoleControl.WPF
The only way I could get it to work is with that Thread.Sleep() in the while loop.
Am I doing something wrong, or is this a bug?
Btw, when I run the code in step-by-step in VS it works fine.
The text was updated successfully, but these errors were encountered: