Sample code for 30+ languages & platforms
Delphi DLL

Sleep for a Number of Milliseconds (FTP Utility)

See more FTP Examples

Demonstrates the Chilkat Ftp2.SleepMs method, which blocks the calling thread for a number of milliseconds. The only argument is the millisecond count. It performs no FTP network operation.

Background: This is a plain convenience wrapper around a thread sleep, provided so scripts and generated examples can pause without pulling in a language-specific timing API. Typical uses are inserting a short delay between polling attempts, or giving a finicky server a moment between operations. It does nothing FTP-specific.

Chilkat Delphi DLL Downloads

Delphi DLL
var
success: Boolean;
ftp: HCkFtp2;
millisec: Integer;

begin
success := False;

//  Demonstrates the Ftp2.SleepMs method, which blocks the calling thread for a number of
//  milliseconds.  The only argument is the number of milliseconds.  It performs no FTP network
//  operation.

ftp := CkFtp2_Create();

CkFtp2_putHostname(ftp,'ftp.example.com');
CkFtp2_putUsername(ftp,'myFtpLogin');

//  Normally you would not hard-code the password in source.  You should instead obtain it
//  from an interactive prompt, environment variable, or a secrets vault.
CkFtp2_putPassword(ftp,'myPassword');

success := CkFtp2_Connect(ftp);
if (success = False) then
  begin
    Memo1.Lines.Add(CkFtp2__lastErrorText(ftp));
    Exit;
  end;

//  A small pause can be useful when polling or when a server needs a moment between operations.
millisec := 500;
CkFtp2_SleepMs(ftp,millisec);
Memo1.Lines.Add('Waited half a second.');

success := CkFtp2_Disconnect(ftp);
if (success = False) then
  begin
    Memo1.Lines.Add(CkFtp2__lastErrorText(ftp));
    Exit;
  end;

CkFtp2_Dispose(ftp);