Time Interval using system.timers. timer in NAV BC

HI Expert,

i want to run my code unit every 5 min, i have tried using Timer dotnet variable but it is not working.
the below code is not trigger, could you please help ?
OnRun()
CounterG := 0;
TimerG :=TimerG.Timer; // create a Timer instance
TimerG.Interval := 30000; // 3 sece
TimerG.Enabled := TRUE;
TimerG.Start;

TimerG::Elapsed(sender : Variant;e : DotNet “System.Timers.ElapsedEventArgs”)
CounterG := CounterG + 1;
CustomerL.INIT;
CustomerL.“No.” := ‘CUST000’+‘’+FORMAT(CounterG) ;
CustomerL.Name := ’ Bala’;
CustomerL.INSERT;
// stop timer after trigger Elapsed was called 10 times
IF CounterG > 10 THEN BEGIN
TimerG.Enabled := FALSE;
TimerG.Stop(); // stops the timer
TimerG.Close();
CLEAR(TimerG);
TextFileG.CLOSE;
END;

Why aren’t you using Job Queue entries to do this?

1 Like

I’d agree with @pjllaneras. Since you only need this to run every 5 minutes, Job Queue should be able to handle this. The potential limitation with Job Queue is it only supports a minimum frequency of 1 minute. It you need a process to run more often, then you need another solution.

Thanks for response, standard Job queue based on minutes only. customer wants based on Sec.

i got the solution, if i use the single instance my code unit it is working.