调用abort()强行终止把,不知行不行。不过的你得把你那10个线程引用保存一下了。
解决方案 »
- 请问下SQLSERVER能设置对每个列检查吗?
- 公交查询系统
- 有没有用过Grid++Report做过报表的?
- zedgraph x轴问题
- C#开发的wince程序的自动升级问题?
- Remoting实例代码
- 在VS2005中能直接用数据库么?
- 怎么远程连接Microsoft Visual SourceSafe
- 如何在教师机上屏幕监看学生机? http://expert.csdn.net/Expert/topic/1620/1620429.xml?temp=.2697107
- 谁能介绍用.net的好公司
- 如何安排treeView控件中的treeNode的层次关系?
- 我想找一些学习C++的书籍或者视频教程
可以试试把他们放在线程池里,来做中止
能说一下怎么样把我的程序改成线程池呢?
谢谢
这是我的理解。
private IntPtr closeEvent;
private string closeEventName = "CloseEvent";//类初始化中
closeEvent = Win32API.CreateEvent(IntPtr.Zero, Convert.ToInt32(true), Convert.ToInt32(false), closeEventName);//线程中
int res = Win32API.WaitForSingleObject(closeEvent, 10);
if ( res == (int)SyncAPIConstants.WAIT_OBJECT_0 )
{
// Exit the thread.
return;
}//关闭
Win32API.SetEvent(closeEvent);
start线程时
Win32API.ResetEvent(closeEvent);//树起关闭
Win32API是?
多谢
public static extern IntPtr CreateEvent(
IntPtr lpEventAttributes,
int bManualReset,
int bInitialState,
string lpName
); [DllImport("kernel32.dll", EntryPoint="SetEvent", SetLastError = true)]
public static extern int SetEvent(IntPtr hEvent); [DllImport("kernel32.dll", EntryPoint="ResetEvent", SetLastError = true)]
public static extern int ResetEvent(IntPtr hEvent); [DllImport("kernel32.dll", EntryPoint="WaitForSingleObject", SetLastError = true)]
internal static extern int WaitForSingleObject(
IntPtr hHandle,
uint dwMilliseconds
);
{
testThread[i] = new Thread(new ThreadStart(aaa));
testThread[i].Start();
}//结束
for (int i=0; i<10; i++)
{
testThread[i].Abort()
}