Comments (4)
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:
while(somethingThatIsTrueForALongTime)
{
somethingThatIsQuickToDo();
}
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?
Stack<string> words = new Stack<String>(new[] { "one", "two", "three" });
void ProcessWords()
{
// Whenever a process is finished, if we still have words left to process, pop the stack
// and start processing the next word.
processInterface.OnProcessExit += (sender, args) =>
{
if (words.Any())
{
processInterface.StartProcess("someprogram", words.Pop());
}
};
// Now just start
StartProcess("something", words.Pop());
}
You can get processInterface
with view.console.ProcessInterface
. Essentially what you are doing here is waiting for a process to exit. When it exists, if there are any words to process, start processing the next available.
from consolecontrol.
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.
from consolecontrol.
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)
{
while(true)
{
try
{
consoleControl1.StartProcess(name, args);
}
catch (System.InvalidOperationException ex)
{
consoleControl1.StopProcess();
Application.DoEvents();
continue;
}
break;
}`
from consolecontrol.
It seems that the process when exits there is still (buffered?) lines to be sent to the richtextbox, and worker is busy with that.
from consolecontrol.
Related Issues (20)
- Can't Launch Node HOT 9
- Handling carriage return for programs that print updates in same place.
- Error in ConsoleControl.WPF + fix HOT 2
- Mystirous ding sound after process stopped HOT 6
- Auto scroll not working after control loses focus HOT 1
- Infinite buffer size
- Parse ANSI Color Codes HOT 1
- WPF Console Sample Does Not Work
- Unable to get ProcessId / or use WaitForExit() HOT 1
- Is it possible to open Ubuntu subsystem? HOT 1
- docs: Document how to wait for a process to exit
- Backspace deletes last readonly character
- ssh is not recognized as a command HOT 1
- Unable to render UTF-8 characters
- Multiple processes
- How to port your repo to be used in .NET 6 winforms or even .NET 7? HOT 1
- New nuget package? HOT 1
- Buffer size is restricted with the internal RichTextBox
- Need help
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from consolecontrol.