public void Start(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(_codeBox.Text)) { _consoleBox.Text = "Empty program"; return; } _consoleBox.Text = "Processing..."; _runButton.IsEnabled = false; var task = new Task(() => { var res = Runners.runTryCatchErrors(_codeBox.Text); if (res.IsError) { OnFinishWithErrors(res.ErrorValue); } else { OnFinish(); } }); task.Start(); }