unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls; type TMY = class(TThread)
public ThreadEnd:boolean;
constructor create(); overload;
destructor Destroy(); overload;
procedure execute; override;
end; TForm1 = class(TForm)
Button1: TButton;
Panel1: TPanel;
Button2: TButton;
Panel2: TPanel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
My: TMY;
public
{ Public declarations }
end; var
Form1: TForm1; implementation {$R *.dfm} constructor TMY.create();
begin
ThreadEnd :=False;
FreeOnTerminate := True;
inherited Create(False);
end;
destructor TMY.Destroy();
begin
inherited Destroy;
end;
procedure TMY.execute;
var i: Integer;
begin
for i := to do
begin
Sleep();
Form1.Panel1.Caption := IntToStr(i); end;
ThreadEnd :=True;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
My := TMY.create;// 执行线程
end;
procedure TForm1.Button2Click(Sender: TObject);
var I:Cardinal;
Isquit:Boolean;
begin Isquit:=GetExitCodeThread(My.handle,i) ;//检查线程是否结束
if Isquit then Button2.Caption:='True' else Button2.Caption:='False';
// My.ThreadEnd=True 也可以确定线程结束。
end;
end.

Delphi 实现检测线程类TThread是否结束的更多相关文章

  1. Delphi中的线程类 - TThread详解

    Delphi中的线程类 - TThread详解 2011年06月27日 星期一 20:28 Delphi中有一个线程类TThread是用来实现多线程编程的,这个绝大多数Delphi书藉都有说到,但基本 ...

  2. Delphi中线程类TThread实现多线程编程1---构造、析构……

    参考:http://www.cnblogs.com/rogee/archive/2010/09/20/1832053.html Delphi中有一个线程类TThread是用来实现多线程编程的,这个绝大 ...

  3. 转发 Delphi中线程类TThread 实现多线程编程

    Delphi中有一个线程类TThread是用来实现多线程编程的,这个绝大多数Delphi书藉都有说到,但基本上都是对TThread类的几个成员作一简单介绍,再说明一下Execute的实现和Synchr ...

  4. Delphi 实现多线程编程的线程类 TThread

    http://blog.csdn.net/henreash/article/details/3183119 Delphi中有一个线程类TThread是用来实现多线程编程的,这个绝大多数Delphi书藉 ...

  5. Delphi中的线程类(转)

    Delphi中的线程类 (转) Delphi中有一个线程类TThread是用来实现多线程编程的,这个绝大多数Delphi书藉都有说到,但基本上都是对 TThread类的几个成员作一简单介绍,再说明一下 ...

  6. 转:学习笔记: Delphi之线程类TThread

    学习笔记: Delphi之线程类TThread - 5207 - 博客园http://www.cnblogs.com/5207/p/4426074.html 新的公司接手的第一份工作就是一个多线程计算 ...

  7. Delphi中线程类TThread实现多线程编程2---事件、临界区、Synchronize、WaitFor……

    接着上文介绍TThread. 现在开始说明 Synchronize和WaitFor 但是在介绍这两个函数之前,需要先介绍另外两个线程同步技术:事件和临界区 事件(Event) 事件(Event)与De ...

  8. 学习笔记: Delphi之线程类TThread

    新的公司接手的第一份工作就是一个多线程计算的小系统.也幸亏最近对线程有了一些学习,这次一接手就起到了作用.但是在实际的开发过程中还是发现了许多的问题,比如挂起与终止的概念都没有弄明白,导致浪费许多的时 ...

  9. Delphi线程类 DIY(把类指针作为参数传进去,就可以执行类里面的方法啦)

    Delphi 封装了一个很强大的线程类 TThread, 我们也自己动手制作一个简单的线程类 首先Type一个类 type TwwThread = class constructor Create;  ...

随机推荐

  1. [译]GLUT教程 - 移动镜头3

    Lighthouse3d.com >> GLUT Tutorial >> Input >> Moving the Camera III 上一节的示例中我们用键盘更改 ...

  2. cat 命令

    cat命令的用途是连接文件或标准输入并打印.这个命令常用来显示文件内容,或者将几个文件连接起来显示,或者从标准输入读取内容并显示,它常与重定向符号配合使用. 1.命令格式: cat [选项] [文件] ...

  3. shell学习五十七天----linux任务管理,针对上一讲的总结和扩展

    linux任务管理 在linux下有两类任务管理,各自是一次性和周期性.一次性是at和batch,周期性又分为系统不论什么和用户任务. 一次性任务: 1.命令格式:at [选项] time 2.选项: ...

  4. Hadoop自带Sort例子分析

    /** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agree ...

  5. warning: push.default is unset; its implicit value is changing in Git 2.0 from 'matching' to 'simple'.

    'matching'参数是 git 1.x 的默认行为,其意是如果你执行 git push 但没有指定分支,它将 push 所有你本地的分支到远程仓库中对应匹配的分支. 而 Git 2.x 默认的是 ...

  6. openWRT自学计划安排

    目标:充分理解openwrt的框架构成,能够在openwrt框架下实现:开发新程序,修改现有程序,修改内核,修改boot.为此,制定如下计划: 一.如何在openwrt上做开发 1.编译出一个BRCM ...

  7. ubuntu 16.04查询文件安装目录

    dpkg -L filename dpkg -l | grep filename whereis filename find / -name filename

  8. 06 Memcached中的一些参数限制

    一: Memcached中的一些参数限制 Key的长度:250字节(二进制协议支持65536个字节) value的限制:1M ,一般都是存储一些文本,如新闻标题等等这个值足够了, 内存的限制:32位下 ...

  9. hdu 4902 Nice boat(线段树区间改动,输出终于序列)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4902 Problem Description There is an old country and ...

  10. Unity 插件收集(持续更新)

    MGS Machinery Unity绑定机械关节,铰链,机构插件包.    MGS Mechanical Drive 用于绑定场景中的机械驱动器的Unity插件   Unity Wave Propa ...