我正在寻找在单独的类库项目中定义的窗口(WPF)作为新的单独进程.有没有办法做到这一点?
我需要在新进程中启动第二个项目实例,因为当我以这种方式启动它时会占用内存:
secondProject.WPFWindow win = new secondProject.WPFWindow();
win.Show();
Run Code Online (Sandbox Code Playgroud)
我有一个包含多个项目的解决方案.
现在我通过以下代码运行"应用程序"(此解决方案中构建为dll的其他项目):
secondProject.WPFWindow win = new secondProject.WPFWindow();
win.Show();
Run Code Online (Sandbox Code Playgroud)
我想要在新进程中运行应用程序...通常我会使用Process.Start(),但我不能这样,因为它需要exe文件作为agrument我有(并且想要)DLL.
我有这个代码:
void wait(int ms)
{
System.Threading.Thread.Sleep(ms);
}
private void button1_Click(object sender, RoutedEventArgs e)
{
info.Text = "step 1";
wait(1000);
info.Text = "step 2";
wait(1000);
info.Text = "step 3";
wait(1000);
info.Text = "step 4";
wait(1000);
}
Run Code Online (Sandbox Code Playgroud)
问题是textbox.text在整个void button1_Click完成后更新.它没有在AIR上更新:(
拜托,怎么办?
我有下一个代码:
private void button_Click(object sender, RoutedEventArgs e)
{
Thread t = new Thread(Process);
t.SetApartmentState(ApartmentState.STA);
t.Name = "ProcessThread";
t.Start();
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
string msg = "Really close?";
MessageBoxResult result =
MessageBox.Show(
msg,
"Closing",
MessageBoxButton.YesNo,
MessageBoxImage.Warning);
if (result == MessageBoxResult.No)
{
e.Cancel = true;
}
}
Run Code Online (Sandbox Code Playgroud)
我需要在private void Window_Closing中进行代码工作,只有当它知道ProcessThread仍然是Alive/InProgress/running时.
类似于IF(GetThreadByName("ProcessThread").IsAlive == true)..
我怎么用C#写的?