Forum > Other

unblocked Sleep() for all Platforms

(1/4) > >>

KodeZwerg:
In Windows i do use this ->


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure Sleep(const AMilliSeconds: DWORD);var  Ret: DWORD;  WaitTime: Int64;  Timer: THandle;begin  Timer := CreateWaitableTimer(nil, TRUE, nil);  WaitTime := Round((AMilliSeconds / 1000) * -10000000);  SetWaitableTimer(Timer, WaitTime, 0, nil, nil, FALSE);  repeat    Ret := MsgWaitForMultipleObjects(1, Timer, FALSE, INFINITE, QS_ALLINPUT);    if (Ret <> (WAIT_OBJECT_0+1)) then      Break;    Application.ProcessMessages;  until False;  if (Ret <> WAIT_OBJECT_0) then    CancelWaitableTimer(Timer);  CloseHandle(Timer);end; to temporarily suspend the workflow without that my application freeze or i do waste CPU.

Since i do use pure Windows Api calls to achieve that, how can i do the same for other OS's?


(I am sorry if i did posted in wrong sub-forum, please move this topic wherever it should be)

Maybe FPC/Lazarus has already something similar included?

Red_prig:
https://www.freepascal.org/docs-html/rtl/sysutils/sleep.html

KodeZwerg:

--- Quote from: Red_prig on August 27, 2022, 04:12:15 pm ---https://www.freepascal.org/docs-html/rtl/sysutils/sleep.html

--- End quote ---

That is blocking. I do need unblocked version. (Application shall not freeze)

Red_prig:
There are definitely none

Red_prig:
In principle you can use https://wiki.lazarus.freepascal.org/TTimer maybe this will work for you

Navigation

[0] Message Index

[#] Next page

Go to full version