在加载过程后完成操作

Fly*_*ynn 3 .net c# visual-studio-2010

问题是我工作的地方有很多计算机文盲.我们有4个应用程序必须按顺序运行,以便这些人可以完成他们的工作.他们必须运行无线卡,然后运行Cisco VPN,在VPN连接后,他们必须运行传输程序,然后是允许他们完成工作订单的移动应用程序.

我的目标是通过让他们可以运行的应用程序逐步运行程序来做出这个愚蠢的证据(或尽可能地证明).截至目前,该程序只有4个按钮,步骤1-4.现在它加载时只有"Step 1"可见,当它们点击它时它运行第一个程序然后显示下一个按钮,并且当前按钮变为绿色,文本表示程序已启动,并且还使其无法点击让他们不要打开一个程序30次(因为他们会).

所有这一切都很棒,按钮按钮.但我想要做的是点击第1步(按钮标签"Step1"),然后在按钮中显示"正在启动程序"的文本,当程序启动时,然后将按钮更改为绿色背景"程序已启动"为文本,然后显示下一个按钮.

这是按钮的代码:

    private void Form1_Load(object sender, EventArgs e)
    {
        Rectangle workingArea = Screen.GetWorkingArea(this);
        this.Location = new Point(workingArea.Right - Size.Width, workingArea.Bottom - Size.Height);
        Step2.Visible = false;
        Step3.Visible = false;
        Step4.Visible = false;
    }

    private void Step1_Click(object sender, EventArgs e)
    {
        Step1.BackColor = Color.LightGreen;
        Step1.Text = "Verizon Wireless Card";
        string strVzWireless = "C:\\Program Files (x86)\\Verizon Wireless\\VZAccess Manager\\VZAccess Manager.exe";
        Process VzWireless = Process.Start(strVzWireless);
        Step2.Visible = true;
        Step1.Enabled = false;
    }

    private void Step2_Click(object sender, EventArgs e)
    {
        Step2.BackColor = Color.LightGreen;
        Step2.Text = "Cisco VPN Client";
        string strCisco = "C:\\Program Files (x86)\\Cisco\\Cisco AnyConnect VPN Client\\vpnui.exe";
        Process Cisco = Process.Start(strCisco);
        Step3.Visible = true;
        Step2.Enabled = false;
    }

    private void Step3_Click(object sender, EventArgs e)
    {
        Step3.BackColor = Color.LightGreen;
        Step3.Text = "Client Rf Transport";
        string strRfTransport = "C:\\MWM\\MobileStation\\RfTransport\\RfTransport.exe";
        Process RfTransport = Process.Start(strRfTransport);
        Step4.Visible = true;
        Step3.Enabled = false;
    }

    private void Step4_Click(object sender, EventArgs e)
    {
        Step4.BackColor = Color.LightGreen;
        Step4.Text = "Mobile Station";
        string strMobileStation = "C:\\MWM\\MobileStation\\Station.exe";
        Process MobileStation = Process.Start(strMobileStation);
        Step4.Enabled = false;
    }
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?我只是希望按钮1根据正在运行的进程的状态更改颜色和文本,然后显示按钮2,依此类推.

Ree*_*sey 6

一种选择是在后台线程上启动您的进程,然后使用Process.WaitForInputIdle()它等待它启动并处于"就绪"状态.然后,您可以启动流程中的第二步,等等.