|
Creates a taske executing process that will run the specified procedure after every N amount of seconds. |
|
Name |
The name of the periodic task. Can be used to terminate the task with RemoveTask |
Desc |
Description that will show up in periodic tasks report |
Procedure |
The name of the procedure to execute |
Variable |
A variable to pass to the periodic function. procedure [ptaskname](string arg) |
Frequency |
The frequency of execution - in seconds |
|
global
updating procedure UpdateUniversityCache(string arg)
begin
record UniversityURLCacheVc UUCr;
record UniversityURLCacheVc oldUUCr;
uuid bluuid;
longint acnt;
array string 255 awindows;
array string 255 auuid;
date d;
time t;
acnt = 0;
while (LoopMain(UUCr,1,true)) begin
switch (UUCr.State) begin
case kUniversityURLStateValid:
// re check if time and date are >limit
if (UniversityCacheRecordExpired(UUCr)) then begin
// client notification, need to validate (uuid is same as on server and thus sent to server)
// fetch immediately
awindows[acnt] = UUCr.WindowName;
auuid[acnt] = UUCr.UUID;
acnt = acnt+1;
end;
case kUniversityURLStateNothing:
// re check if time and date are >limit
if (UniversityCacheRecordExpired(UUCr)) then begin
// client notification, need to fetch (uuid is blanked when sending to server)
// fetch immediately and change State to Requesting
RecordCopy(oldUUCr,UUCr);
UUCr.State = kUniversityURLStateRequesting;
RecordUpdate(oldUUCr,UUCr,false);
UUCr.UUID = bluuid;
awindows[acnt] = UUCr.WindowName;
auuid[acnt] = UUCr.UUID;
acnt = acnt+1;
end;
case kUniversityURLStateRequest:
// client notification, need to fetch (uuid is blanked when sending to server)
// fetch immediately and change State to Requesting
RecordCopy(oldUUCr,UUCr);
UUCr.State = kUniversityURLStateRequesting;
RecordUpdate(oldUUCr,UUCr,false);
UUCr.UUID = bluuid;
awindows[acnt] = UUCr.WindowName;
auuid[acnt] = UUCr.UUID;
acnt = acnt+1;
end;
end;
if (acnt>0) then begin
// send request to server
QueryELearningServer(awindows,auuid,acnt);
end;
out:;
if (arg=="startup") then begin
NewPeriodicTask("UpdateUniversityCache","UpdateUniversityCache","UpdateUniversityCache","",300);
end;
return;
end;
|
««