From Clomosy Docs
No edit summary |
ClomosyAdmin (talk | contribs) No edit summary |
||
| (4 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
<div class="alert alert-ligth border border-3 border-primary-subtle rounded-5 p-4 shadow-sm" role="alert"> | |||
procedure Clomosy.SleepAndCall(millisecond:Integer,BeforeSleep,AfterSleep:String); | |||
</div> | |||
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.<br> | |||
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. | 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.<br> | ||
<b>Example</b><br> | |||
<pre> | |||
var | |||
MyForm:TclForm; | MyForm:TclForm; | ||
sleepBtn : TclButton; | sleepBtn : TclButton; | ||
void getAfterSleep; | |||
{ | |||
sleepBtn.Text | sleepBtn.Text = 'AFTER SleepAndCall'; | ||
} | |||
void getBeforeSleep; | |||
{ | |||
sleepBtn.Text | sleepBtn.Text = 'BEFORE SleepAndCall'; | ||
//MyForm.StartProcessMessages(5000); | //MyForm.StartProcessMessages(5000); | ||
Clomosy.SleepAndCall(3000, | Clomosy.SleepAndCall(3000,'','getAfterSleep'); | ||
} | |||
{ | |||
MyForm | MyForm = TclForm.Create(Self); | ||
sleepBtn | sleepBtn= MyForm.AddNewButton(MyForm,'sleepBtn','Click'); | ||
sleepBtn.TextSettings.Font.Size | sleepBtn.TextSettings.Font.Size=30; | ||
sleepBtn.Align | sleepBtn.Align = alCenter; | ||
sleepBtn.Height | sleepBtn.Height = 70; | ||
sleepBtn.Width | sleepBtn.Width = 200; | ||
MyForm.AddNewEvent(sleepBtn,tbeOnClick,'getBeforeSleep'); | MyForm.AddNewEvent(sleepBtn,tbeOnClick,'getBeforeSleep'); | ||
MyForm.Run; | MyForm.Run; | ||
} | |||
</pre> | |||
<h2> See Also </h2> | |||
* [[Clomosy_Class#System_Function | System Functions]] | |||
{{#seo:|title=SleepAndCall Using in Clomosy - Clomosy Docs}} | |||
{{#seo:|description=Learn how the SleepAndCall function in Clomosy waits for a specified duration before executing callback functions before and after the wait.}} | |||
Latest revision as of 13:34, 24 December 2024
procedure Clomosy.SleepAndCall(millisecond:Integer,BeforeSleep,AfterSleep:String);
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.
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
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;
}