frmkeepitup.cs

来自「Microsoft Mobile Development Handbook的代码」· CS 代码 · 共 40 行

CS
40
字号
using System;
using System.Windows.Forms;
using System.Threading;

namespace CodeForChapter11cs
{
  // Only run this from within the IDE with F5
  public partial class frmKeepItUp : Form
  {
    public frmKeepItUp()
    {
      InitializeComponent();
    }

    // start thread that will block
    private void menuItem1_Click(object sender, EventArgs e)
    {
      Thread t = new Thread(new ThreadStart(this.KeepTheProcessUp));
      //t.IsBackground = true;
      t.Start();

      MessageBox.Show("Hit the Exit button. Is VS still debugging");
    }

    private void KeepTheProcessUp()
    {
      ManualResetEvent mre = new ManualResetEvent(false);
      mre.WaitOne();
      MessageBox.Show("Never shown!");
      // imagine more code
    }

    //Exit
    private void menuItem2_Click(object sender, EventArgs e)
    {
      this.Close();
      Application.Exit(); // utterly superfluous but just to emphasize the point!
    }
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?