【发布时间】:2018-10-24 12:39:53
【问题描述】:
我正在开发 WPF 应用程序。现在我正在尝试做这样的事情:
//Print the information about what happened, and open toolbar.
MessageBox.Show("Cannot find the destination file, The application will now open Google Chrome." + Environment.NewLine
+ "Please fill in the information and when you finish close Google Chrome.");
//open Attributes Toolbar
new AttributesToolbar(application.Attributes).Show();
//start google chrome and wait for the user to close it
Process.Start(startInfo).WaitForExit();
var success = (MessageBox.Show("Did you succeed?", "Status check", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes);
return new RPAResult()
{
Succeeded = success
};
这些是步骤:
1) 应用程序找不到配置文件后,它会打印一条消息,用户必须自己填写一些细节(这是背景故事,不是那么重要)。
2) 应用程序打开一个工具栏窗口 - 这是一个 WPF 窗口,其中包含用户必须从其中复制并粘贴到 chrome 页面的一些详细信息。
3) 应用程序打开谷歌浏览器并等待用户关闭它
问题是当执行“WaitForExit()”命令时,整个应用程序都被冻结了,即使是刚刚打开的新 WPF 窗口,用户也无法复制和粘贴任何内容。
我尝试打开一个新线程,但它会导致 STAThread 问题。
有什么帮助吗?
【问题讨论】:
-
你用什么代码打开了一个新线程,你的“STAThread问题”遇到了什么错误?