X xf_z Unregistered / Unconfirmed GUEST, unregistred user! 2009-07-01 #1 在线程中使用如下语句设置timerSettimer(0,1,1000,@mytimer1);只要线程不退timer就一直生效,线程一结束timer就自动关了,该怎么解决呀?我想让线程退了timer继续可以使用
在线程中使用如下语句设置timerSettimer(0,1,1000,@mytimer1);只要线程不退timer就一直生效,线程一结束timer就自动关了,该怎么解决呀?我想让线程退了timer继续可以使用
S smlabc Unregistered / Unconfirmed GUEST, unregistred user! 2009-07-01 #2 既然都用了线程,还用Timer做什么?//线程中写while Truedo begin Sleep(1000); //写Timer中代码end;
X xf_z Unregistered / Unconfirmed GUEST, unregistred user! 2009-07-01 #3 可是我想让这个线程退了啊,我就是想让线程退出后timer还生效
F fanronghua Unregistered / Unconfirmed GUEST, unregistred user! 2009-07-01 #4 unit UnitTestThrad;interfaceuses WinProcs, Classes, Graphics, ExtCtrls;type TTestThrad = class(TThread) private CloseTimer: TTimer; procedure CloseTimerTimer(Sender: TObject); protected procedure Execute; override; public constructor Create(); destructor Destroy; override; procedure CloseThread; end; implementation{ TTestThrad }procedure TTestThrad.CloseThread; begin end; procedure TTestThrad.CloseTimerTimer(Sender: TObject); begin //end; constructor TTestThrad.Create; begin inherited Create(false); CloseTimer := TTimer.Create(nil); CloseTimer.OnTimer := CloseTimerTimer; CloseTimer.Interval := 1000; CloseTimer.Enabled := true; end; destructor TTestThrad.Destroy; begin inherited; end; procedure TTestThrad.Execute; begin inherited; while not Self.Terminateddo begin // end; CloseTimer.Enabled := false; end; end.
unit UnitTestThrad;interfaceuses WinProcs, Classes, Graphics, ExtCtrls;type TTestThrad = class(TThread) private CloseTimer: TTimer; procedure CloseTimerTimer(Sender: TObject); protected procedure Execute; override; public constructor Create(); destructor Destroy; override; procedure CloseThread; end; implementation{ TTestThrad }procedure TTestThrad.CloseThread; begin end; procedure TTestThrad.CloseTimerTimer(Sender: TObject); begin //end; constructor TTestThrad.Create; begin inherited Create(false); CloseTimer := TTimer.Create(nil); CloseTimer.OnTimer := CloseTimerTimer; CloseTimer.Interval := 1000; CloseTimer.Enabled := true; end; destructor TTestThrad.Destroy; begin inherited; end; procedure TTestThrad.Execute; begin inherited; while not Self.Terminateddo begin // end; CloseTimer.Enabled := false; end; end.