所以这个在我的主wpf中的类不能处理5,我试图在主窗口cs的同时运行这个类,这可能吗? 主要问题:class1不允许我启动私有进程,如在mainwindow.xaml.cs
中using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WpfApplication3
{
private object process5;
class Class1
{
process5 = Process.Start("notepad.exe");
}
}
但是在主窗口中,进程1-4可以:
public partial class MainWindow : Window
{
private object process1;
private object process2;
private object process3;
private object process4;
public MainWindow()
{
/*
Task.Run(() => process1 = Process.Start("notepad.exe"));
Task.Run(() => process2 = Process.Start("calc.exe"));
Task.Run(() => process3 = Process.Start("c:\\windows\\explorer.exe"));
Task.Run(() => process4 = Process.Start("C:\\Program Files\\Adobe\\Adobe Audition CC\\Adobe Audition CC.exe"));
*/
System.Threading.Tasks.Task.Factory.StartNew(() => process1 = Process.Start("notepad.exe"));
System.Threading.Tasks.Task.Factory.StartNew(() => process2 = Process.Start("calc.exe"));
System.Threading.Tasks.Task.Factory.StartNew(() => process3 = Process.Start("c:\\windows\\explorer.exe"));
System.Threading.Tasks.Task.Factory.StartNew(() => process4 = Process.Start("C:\\Program Files\\Adobe\\Adobe Audition CC\\Adobe Audition CC.exe"));
InitializeComponent();
}
public static void MainWindow2()
{
int f = 23;
int g = 25;
MessageBox.Show("f + g = " + "" + f + g);
}
private void button1_click(object sender, RoutedEventArgs e)
{
MessageBox.Show("hi");
}
}
}
答案 0 :(得分:0)
没有这种能力在命名空间级别拥有对象属性。
namespace WpfApplication3
{
private object process5;