procedure TForm1.Button1Click(Sender: TObject); var task: ITask; begin FAccessor.Enter(); try if (FWorkInProgress) then Exit; FWorkInProgress := true; finally FAccessor.Leave(); end; FNeedShowText := cbShowText.Checked; task := TTask.Create(procedure() var html: TStrings; begin html := TStringList.Create(); try TThread.Synchronize(nil, procedure() begin Memo1.Lines.Clear(); end); clHttp1.Get(edtUrl.Text, html); if FNeedShowText then begin clHtmlParser1.Parse(html); end else begin TThread.Synchronize(nil, procedure() begin Memo1.Lines.Assign(html); end); end; finally FAccessor.Enter(); try FWorkInProgress := False; finally FAccessor.Leave(); end; html.Free(); end; end); task.Start(); end;
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean); begin FAccessor.Enter(); try if (FWorkInProgress) then begin ShowMessage('The work is in progress, cannot close the program.'); CanClose := False; end; finally FAccessor.Leave(); end; end; procedure TForm1.clHtmlParser1ParseTag(Sender: TObject; ATag: TclHtmlTag); begin if (Trim(ATag.Text) <> '') then TThread.Synchronize(nil, procedure() begin Memo1.Lines.Add(ATag.Text); end); end;
Trouble logging in? Simply enter your email address OR username in order to reset your password.
For faster and more reliable delivery, add admin@clevercomponents.com to your trusted senders list in your email software.