如何察看通过多线程建立的MDI子窗体的各自的线程ID
private void btnCreate_Click(object sender, EventArgs e)
{
Thread t = new Thread(new ThreadStart(CreateMDI));
t.Name = "Line " + dropLineNo.Text;
t.Start();
}
private void InvokeFun()
{
MdiChild formMdiChild = new MdiChild();
formMdiChild.LineNo = int.Parse(dropLineNo.Text);
formMdiChild.MdiParent = this;
formMdiChild.Show();
}
private void CreateMDI()
{
MethodInvoker mi = new MethodInvoker(this.InvokeFun);
BeginInvoke(mi);
}
===================================================================
以上是通过线程建立MDI子窗体, 在MDI子窗体中,我通过 Thread.CurrentThread.ManagedThreadId 显示线程ID,发现都一样的,为什么
===================================================================
private void MdiChild_Load(object sender, EventArgs e)
{
this.Text = Thread.CurrentThread.ManagedThreadId.ToString();
}
------解决方案--------------------Invoke里面可以out ThreadID的
参考:
http://msdn2.microsoft.com/en-us/library/2e08f6yc.aspx