If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > How to create Thread in delphi (window2000 OS)

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-16-04, 22:54
LEMON LEMON is offline
Registered User
 
Join Date: Jan 2004
Location: China GuangZhou
Posts: 2
Red face How to create Thread in delphi (window2000 OS)

Can you help me ?
I spent considerable time to try create a thread in delphi
(base on os win2000) ,but failed.
I know that ,if (base on os win98) ,create a thread in delphi,
it is easy.
Thanks !!!
help me please..
Reply With Quote
  #2 (permalink)  
Old 01-19-04, 17:18
Caden Caden is offline
Registered User
 
Join Date: Jan 2004
Location: Saint Louis /USA
Posts: 8
Re: How to create Thread in delphi (window2000 OS)

Quote:
Originally posted by LEMON
Can you help me ?
I spent considerable time to try create a thread in delphi
(base on os win2000) ,but failed.
I know that ,if (base on os win98) ,create a thread in delphi,
it is easy.
Thanks !!!
help me please..
This is a counter. I thing that would be enought to give you an ideea of how it works.
Regards

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type

mit = class(TThread)
private
i: Byte;
protected
procedure execute; override;
procedure dosomething;
procedure DoVisual;
public
constructor Create;
end;

TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Label1: TLabel;
Button3: TButton;
Button4: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
MyThread: mit;
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

{ mit }

constructor mit.Create;
begin
inherited Create(False);
end;

procedure mit.DoVisual;
begin
Form1.label1.Caption := IntToStr(i);
end;

procedure mit.execute;
begin
dosomething;
end;

procedure mit.dosomething;
var
j: Byte;
begin
repeat
for j := 1 to 50 do
begin
i := j;
Synchronize(dovisual);
if Terminated then
begin
i:=0;
synchronize(dovisual);
Exit;
end;
sleep(500);
end;
until True;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
MyThread := mit.Create;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
Mythread.Terminate;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
Mythread.Suspend;
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
Mythread.Resume;
end;
Reply With Quote
  #3 (permalink)  
Old 01-28-04, 09:19
LEMON LEMON is offline
Registered User
 
Join Date: Jan 2004
Location: China GuangZhou
Posts: 2
Talking thank you

thanks for your help
Reply With Quote
  #4 (permalink)  
Old 01-28-04, 18:51
Mike Collier Mike Collier is offline
Registered User
 
Join Date: Jan 2004
Posts: 31
See also the thread demo in your delphi demos directory
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On