procedure TVisDataThread.Execute;
const
_SECOND = 10000000;
var
qwDueTime: Int64;
liDueTime: _LARGE_INTEGER;
ErrMsg:
string;
begin
if FVisTimer = 0
then
Exit;
// Create a negative 64-bit integer that will be used to
// signal the timer 1/4 seconds from now.
qwDueTime := -1 * (_SECOND
div 4);
// Copy the relative time into a LARGE_INTEGER.
liDueTime.LowPart := DWORD(qwDueTime
and $FFFFFFFF);
liDueTime.HighPart := longint(qwDueTime
shr 32);
if MySetWaitableTimer(FVisTimer,
// handle to a timer object
TLargeInteger(liDueTime),
// when timer will become signaled
FDelayMS,
// periodic timer interval
nil,
// pointer to the completion routine
nil,
// data passed to the completion routine
False
{flag for resume state})
then
// Following sentences are repeated every FDelayMS interval all the time from initial
// start up to program end.
repeat
// We need to re-adjust timer interval according to the parameter "DelayMS" of vis plug-in.
// (in case we exchange vis plug-ins)
if FDelayMSChanged
then
begin
FDelayMSChanged := False;
CancelWaitableTimer(FVisTimer);
MySetWaitableTimer(FVisTimer, TLargeInteger(liDueTime), FDelayMS,
nil,
nil, False);
end;
if WaitForSingleObject(FVisTimer, 1000
{1sec}) = WAIT_OBJECT_0
then
begin
DoOnVisTimer;
end else
Terminate;
SuspendIfHalted;
until Terminated
else
begin
ErrMsg := SysErrorMessage(GetLastError);
ShowErrorMsgBox(ErrMsg);
Terminate;
end;
end;