C
colonel
Unregistered / Unconfirmed
GUEST, unregistred user!
怎么我在线程类中使用TDownLoadURL,该项线程我用了"FreeOnTerminate:= True;"但它怎么也不结束,有时会正常结束,还有以下代码设计合理吗?<br>TMyDownLoadThread = class(TThread)<br>private<br>FDownLoadURL: TDownLoadURL;<br>procedure DoDownloadProgress(Sender: TDownLoadURL; Progress,<br> ProgressMax: Cardinal; StatusCode: TURLDownloadStatus; StatusText: String;<br> var Cancel: Boolean);<br>public<br>property OnDownloadProgress: THeUpFileProgress read FOnDownloadProgress write FOnDownloadProgress;<br>end;<br><br><br>constructor TMyDownLoadThread .Create(const AUrl, ASaveFile: string; AutoLoad: Boolean);<br>begin<br>//....<br>FDownLoadURL.OnDownloadProgress:= Self.DoDownloadProgress;<br>//...<br>end;<br><br>procedure TMyDownLoadThread .Execute;<br>begin<br>//..<br> FDownLoadURL.ExecuteTarget(FDownLoadURL);//就是有时停在这里,明明文件已下载完还是不会再执行下面的代码<br> //..<br>end;<br><br>procedure TMyDownLoadThread .DoDownloadProgress(Sender: TDownLoadURL; Progress,<br> ProgressMax: Cardinal; StatusCode: TURLDownloadStatus;<br> StatusText: String; var Cancel: Boolean);<br>begin<br> if Assigned(FOnDownloadProgress) then<br> FOnDownloadProgress(Self, StatusText, Progress, ProgressMax, FStatusCode);<br>end;