📄 frmsimple.cs
字号:
using System;
using System.Windows.Forms;
using System.Threading;
namespace CodeForChapter11cs
{
public partial class frmSimple : Form
{
public frmSimple()
{
InitializeComponent();
}
private void DoSomeWork()
{
// TODO some work
Thread.Sleep(5000);
Thread t = Thread.CurrentThread;
MessageBox.Show("This thread is " + t.Name +
", id=" + t.ManagedThreadId.ToString());
}
private void menuItem1_Click(object sender, EventArgs e)
{
// UI thread
this.DoSomeWork();
}
private void menuItem2_Click(object sender, EventArgs e)
{
// worker thread
Thread t = new Thread(new ThreadStart(this.DoSomeWork));
t.Name = "Worker Thread 1";
t.Start(); // thread does not execute until this line
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -