The last part is IMO the most complicated and can be handled several ways, but since you mentioned waiting with processing a method, I'll stick to that.
What you have to do is initialize some variable when the waiting starts - usually by something triggering a callback, eg:
[c]
VAR countWaits : Integer;
VAR startTime : Single;
VAR doUpdate : Boolean;
....
PROCEDURE Callback(n : Integer);
...
<some_callback>
countWaits := 0;
startTime := timeMs;
doUpdate := TRUE;
...
[/c]
Then you have to check within Process whether it's about time to do something:
[c]
PROCEDURE Process;
...
IF (doUpdate) THEN BEGIN
countWaits := countWaits + 1;
IF (countWaits >= no_of_waits) THEN BEGIN
do_something;
doUpdate := FALSE;
...
IF (doUpdate) THEN BEGIN
IF ((timeMs - startTime) >= time_to_wait) THEN BEGIN
do_something;
doUpdate := FALSE;
...
[/c]
When queueing data, you wouldn't normally have any use for something like the doUpdate boolean, but instead you'd be checking whether there was anything left in the queue to handled.
Hope this helps.Statistics: Posted by bsork — 14 Dec 2010, 14:52
]]>