TTMSFNCCloudGoogleGmail - How to cancel GetMails

When I request mail vom gmail with for example gmail.GetMails('INBOX',1000,true), how to I cancel it once its running?

Hi,


You can use the following code to loop through the running requests:


procedure TForm1.Button1Click(Sender: TObject);
var

  r: TTMSFNCCloudBaseRequestResult;

begin
  for I := 0 to TMSFNCCloudGoogleGMail1.RunningRequests.Count - 1 do
  begin
    r := TTMSFNCCloudBaseRequestResult(TMSFNCCloudGoogleGMail1.RunningRequests);
    if r.Running then
      r.Cancel;
  end;
end;


and the following code to capture when the request is finished:


procedure TForm1.FormCreate(Sender: TObject);
begin
  TMSFNCCloudGoogleGMail1.OnRequestCancelled := DoRequestCancelled;
end;



procedure TForm1.DoRequestCancelled(Sender: TObject; const ARequestResult: TTMSFNCCloudBaseRequestResult);
begin
  TMSFNCCloudGoogleGMail1.RunningRequests.Remove(ARequestResult);
end;


Pieter Scheldeman2019-12-16 10:11:33

This code seems not to do anything.


Also, what is class procedure TTMSFNCCloudGoogleGMailService ?

I am not using the demo, I just drop the gmail component and call gmail.GetMails(...) and want to abort it. What do I need to add in order for it to work?

I've updated the code above.

It always only removed 16 requests, and after that continue

It does not matter if I want to received 30 or 100 emails, it removes 16, and then continue until the last email.

I clicked to cancel after the 5th. email, executing your example code to cancel.

Received email 1/30
Received email 2/30
Received email 3/30
Received email 4/30
Received email 5/30
Removed 
Removed 
Removed 
Removed 
Removed 
Removed 
Removed 
Removed 
Removed 
Removed 
Removed 
Removed 
Removed 
Removed 
Removed 
Removed 
Received email 6/30
Received email 7/30
Received email 8/30
Received email 9/30
Received email 10/30
Received email 11/30
Received email 12/30
Received email 13/30
Received email 14/30