dwmkerr / consolecontrol

ConsoleControl is a C# class library that lets you embed a console in a WinForms or WPF application.
MIT License
723 stars 169 forks source link

Stopping process throws error #20

Open longlostbro opened 9 years ago

longlostbro commented 9 years ago

calling consoleControl.StopProcess(); from a wpf button or stopping the process from within the process causes an error in the following function.

public bool ShowDiagnostics { get { return (bool)GetValue(ShowDiagnosticsProperty); } set { SetValue(ShowDiagnosticsProperty, value); } } An unhandled exception of type 'System.InvalidOperationException' occurred in WindowsBase.dll Additional information: The calling thread cannot access this object because a different thread owns it."
AtryFox commented 9 years ago

Very nice library, but i'm having the same issue.

foreach(ConsoleControl.ConsoleControl console in cmds.Keys) {
    if (console.IsProcessRunning) console.StopProcess();
    // some console.StartProcess code...
}