If t.ThreadState = ThreadState.Stopped Then
'完成
EndIf
'完成
EndIf
解决方案 »
- group by 用linq或EF怎么写
- sohighthesky 请进
- 请教一下.net 组件使用
- 数据绑定的问题,求救,在线等,谢谢~
- GridView的RowDataBound()中如何处理其Cell[n]为Null?
- 本机不报错,放上服务器报错
- 有些网站上一些图片上的字是动态的,比如是你的ip什么的,这是怎么搞出来的啊,动态生成图片吗?咋搞的
- 又出现一个应用程序中的服务器错误,请大家帮忙?
- 菜鸟关于access数据库的连接问题
- 大家给我帮帮忙推荐一下,现在市场上国产的.net 打印控件那个比较好,我想买一个!
- 下了N个都不能接收邮件,谁给我一个可以用的jmail4.4pro(mail:[email protected])
- 页面上的图片是动态显示的,移动上时,弹出一个图层,图层有很多超链接的记录,点击打开时,转到相应的界面?
try
{
Console.Title = "博客搬家后台服务 --Sean Pu 2007.08.23)";
Parse.Cl("博客搬家后台服务开始运行...", ConsoleColor.DarkGreen);
mThread.MainThread(); //Start MainThread and MainThread start some child threads
XXX
mThread.TerminateThread();//terminate child threads
Parse.Cl("现在开始停止所有服务,请稍等片刻....");
while (myThread.ThreadNum != 0)
{
System.Threading.Thread.Sleep(100);
}
Console.Beep();
Parse.Cl("博客搬家后台服务停止完成.");
Parse.Cl("Press any key to continue... ...");
Console.ReadKey();
}
using System.Threading;public sealed class App
{
// Define an array with two AutoResetEvent WaitHandles.
static WaitHandle[] waitHandles = new WaitHandle[]
{
new AutoResetEvent(false),
new AutoResetEvent(false)
}; // Define a random number generator for testing.
static Random r = new Random(); static void Main()
{
DateTime dt = DateTime.Now;
Console.WriteLine("Main thread is waiting for BOTH tasks to complete.");
ThreadPool.QueueUserWorkItem(new WaitCallback(DoTask), waitHandles[0]);
ThreadPool.QueueUserWorkItem(new WaitCallback(DoTask), waitHandles[1]);
WaitHandle.WaitAll(waitHandles);
Console.WriteLine("Both tasks are completed (time waited={0})",
(DateTime.Now - dt).TotalMilliseconds); // Queue up two tasks on two different threads;
// wait until any tasks are completed.
dt = DateTime.Now;
Console.WriteLine();
Console.WriteLine("The main thread is waiting for either task to complete.");
ThreadPool.QueueUserWorkItem(new WaitCallback(DoTask), waitHandles[0]);
ThreadPool.QueueUserWorkItem(new WaitCallback(DoTask), waitHandles[1]);
int index = WaitHandle.WaitAny(waitHandles);
// The time shown below should match the shortest task.
Console.WriteLine("Task {0} finished first (time waited={1}).",
index + 1, (DateTime.Now - dt).TotalMilliseconds);
} static void DoTask(Object state)
{
AutoResetEvent are = (AutoResetEvent) state;
int time = 1000 * r.Next(2, 10);
Console.WriteLine("Performing a task for {0} milliseconds.", time);
Thread.Sleep(time);
are.Set();
}
}
for (int j=0;j<10 && !q1->Eof;j++)
{
MainForm->Memo2->Lines->Add(DateTimeToStr(Date()+Time())+" 检测 "+q1->FieldByName("ip")->AsString);
//MainForm->Label3->Caption=IntToStr(MainForm->Label3->Caption.ToInt()+1);
checkrun[j]=new CheckIp(false);
checkrun[j]->FreeOnTerminate=false;
checkrun[j]->ip=q1->FieldByName("ip")->AsString;
checkrun[j]->port=q1->FieldByName("port")->AsString.ToInt();
checkrun[j]->Resume();
q1->MoveBy(1);
}
for (;checkrun[0]->islive || checkrun[1]->islive || checkrun[2]->islive || checkrun[3]->islive || checkrun[4]->islive || checkrun[5]->islive || checkrun[6]->islive || checkrun[7]->islive || checkrun[8]->islive || checkrun[9]->islive;)
Sleep(1000);
delete checkrun;
__fastcall CheckIp::CheckIp(bool CreateSuspended)
: TThread(CreateSuspended)
{
islive=true;
}
//---------------------------------------------------------------------------
void __fastcall CheckIp::Execute()
{
//---- Place thread code here ----
//我的程序代码.....
islive=false;
return;
}