How to prevent hints interrupting a timer

亡梦爱人 提交于 2019-12-04 21:15:51

You are calling Application.ProcessMessages from a background thread. Don't do that!

  1. When you do this, you are causing Windows messages to be processed in a non-main thread. VCL doesn't expect that and this can cause various problems.
  2. By calling ProcessMessages you are introducing a delay of unknown length. You don't know how long it will take for ProcessMessages to return.
  3. There's no need to process messages in the background thread. If you have nothing to do, call Sleep(0) or SwitchToThread.

Re 3: You can use something like this:

procedure Yield;
begin
  if Win32Platform = VER_PLATFORM_WIN32_NT then
    asm pause; end
  else
    Sleep(0);
end;
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!