请问各位大虾:
1.能不能线程中又包含有线程?
例如:一个按钮事件中执行这样一个线程:{Thread Thread1 = new Thread(new ThreadStart(get));
Thread1.Start();}
get方法中又有线程在执行:
public void get()
{
Thread Thread2 = null;new Thread(new ThreadStart(getData));
try
{
Thread2 =new Thread(new ThreadStart(getData));
Thread2.Start();
if (sInfo != string.Empty)
{
Thread Thread3 = new Thread(new ThreadStart(sendInfo));
Thread3 .Start();
}
}
catch
{
if (thisThread.IsAlive)
{
thisThread.Abort();
}
}
}
2.在执行线程Thread1的时候我想让线程Thread2执行结束了才开始执行线程Thread3,请问各位大虾,我应该怎么做?
1.能不能线程中又包含有线程?
例如:一个按钮事件中执行这样一个线程:{Thread Thread1 = new Thread(new ThreadStart(get));
Thread1.Start();}
get方法中又有线程在执行:
public void get()
{
Thread Thread2 = null;new Thread(new ThreadStart(getData));
try
{
Thread2 =new Thread(new ThreadStart(getData));
Thread2.Start();
if (sInfo != string.Empty)
{
Thread Thread3 = new Thread(new ThreadStart(sendInfo));
Thread3 .Start();
}
}
catch
{
if (thisThread.IsAlive)
{
thisThread.Abort();
}
}
}
2.在执行线程Thread1的时候我想让线程Thread2执行结束了才开始执行线程Thread3,请问各位大虾,我应该怎么做?
解决方案 »
- 我想先发布程序,然后单独发布水晶报表, 能实现吗?
- vs2005 c# + sql2000,求条码打印相关的代码..
- 假如一个类有10个变量name0,name1,name2,…name9.只是后缀不同,为依次递增。想运行时通过for循环,依次对其赋值,怎么实现。
- 无聊的小问题
- 一个DataTable与Query的问题
- 续 C# PK VB.net
- 用户名
- 想统计一个部门一年使用物品的总和,怎么办??
- 两个Datatable进行合并
- 哪里有比较详细的struct用法的介绍?我这里有一个关于Combobox和结构的问题
- VC写的activeX控件可以c#中使用吗?
- 同一textBox,如何區分'硬回車"和"軟回車"
线程池,还真没有接触过
其他高手也给小弟点解决方法吧
{
Thread Thread2 = null;new Thread(new ThreadStart(getData));
try
{
Thread2 =new Thread(new ThreadStart(getData));
Thread2.Start();
Thread2.Join(); if (sInfo != string.Empty)
{
Thread Thread3 = new Thread(new ThreadStart(sendInfo));
Thread3 .Start();
}
}
catch
{
if (thisThread.IsAlive)
{
thisThread.Abort();
}
}
}
Get()
{
Thread thread2 = new ...;
thread2.Start();
thread2.Join(); //等待线程结束
Thread thread3 = new ...;
thread3.Start();
}
2.(1)如楼上的用join
(2)写回调方法,当线程2结束时回调,回调方法里则是开始线程3