Skip to content

BackgroundWorker is busy even after IsProcessRunning is false #51

Description

@Loucool111

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

foreach (string word in words)
{
	bool isRunning = view.console.Dispatcher.Invoke(() => view.console.IsProcessRunning);

	while (isRunning)
	{
		//Wait and query again after 250ms
		//Thread.Sleep(250);
		isRunning = view.console.Dispatcher.Invoke(() => view.console.IsProcessRunning);
	}

	view.console.Dispatcher.Invoke(new Action<string, string>(view.console.StartProcess), executablePath, cliArguments + word);
}

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions