From Clomosy Docs

(Created page with "The sleepAndCall function represents a function that waits for a specific duration and then executes a specified callback function. This type of function can be used to wait for the completion of a specific task and then proceed to execute another function. Clomosy.SleepAndCall(millisecond,<nowiki>'',''</nowiki>); The first parameter specifies the duration to wait (in milliseconds). The second parameter represents the action to be triggered before the waiting process....")
 
No edit summary
Line 6: Line 6:


'''Example:'''<br>
'''Example:'''<br>
:''Basic Syntax''
  var
  var
   MyForm:TclForm;
   MyForm:TclForm;
Line 35: Line 36:
   
   
  end;
  end;
:''TRObject Syntax''
var
MyForm:TclForm;
sleepBtn : TclButton;
void getAfterSleep;
{
sleepBtn.Text = 'AFTER SleepAndCall';
}
void getBeforeSleep;
{
sleepBtn.Text = 'BEFORE SleepAndCall';
//MyForm.StartProcessMessages(5000);
Clomosy.SleepAndCall(3000,<nowiki>''</nowiki>,'getAfterSleep');
}
{
MyForm = TclForm.Create(Self);
sleepBtn= MyForm.AddNewButton(MyForm,'sleepBtn','Click');
sleepBtn.TextSettings.Font.Size=30;
sleepBtn.Align = alCenter;
sleepBtn.Height = 70;
sleepBtn.Width = 200;
MyForm.AddNewEvent(sleepBtn,tbeOnClick,'getBeforeSleep');
MyForm.Run;
}

Revision as of 10:36, 5 December 2023

The sleepAndCall function represents a function that waits for a specific duration and then executes a specified callback function. This type of function can be used to wait for the completion of a specific task and then proceed to execute another function.

Clomosy.SleepAndCall(millisecond,'','');

The first parameter specifies the duration to wait (in milliseconds). The second parameter represents the action to be triggered before the waiting process. The third parameter executes the specified callback function after the waiting process is completed.

Example:

Basic Syntax
var
 MyForm:TclForm;
 sleepBtn : TclButton;

Procedure getAfterSleep;
begin
 sleepBtn.Text := 'AFTER SleepAndCall';
end;

Procedure getBeforeSleep;
begin
 sleepBtn.Text := 'BEFORE SleepAndCall';
 //MyForm.StartProcessMessages(5000);
 Clomosy.SleepAndCall(3000,'','getAfterSleep');
end;

begin
 MyForm := TclForm.Create(Self);
 sleepBtn:= MyForm.AddNewButton(MyForm,'sleepBtn','Click');
 sleepBtn.TextSettings.Font.Size:=30;
 sleepBtn.Align := alCenter;
 sleepBtn.Height := 70;
 sleepBtn.Width := 200;

 MyForm.AddNewEvent(sleepBtn,tbeOnClick,'getBeforeSleep');

 MyForm.Run;

end;
TRObject Syntax
var
MyForm:TclForm;
sleepBtn : TclButton;

void getAfterSleep;
{
sleepBtn.Text = 'AFTER SleepAndCall';
}

void getBeforeSleep;
{
sleepBtn.Text = 'BEFORE SleepAndCall';
//MyForm.StartProcessMessages(5000);
Clomosy.SleepAndCall(3000,'','getAfterSleep');
}

{
MyForm = TclForm.Create(Self);
sleepBtn= MyForm.AddNewButton(MyForm,'sleepBtn','Click');
sleepBtn.TextSettings.Font.Size=30;
sleepBtn.Align = alCenter;
sleepBtn.Height = 70;
sleepBtn.Width = 200;

MyForm.AddNewEvent(sleepBtn,tbeOnClick,'getBeforeSleep');

MyForm.Run;

}