Timer

XaviXavi Member Posts: 26
I want to call a function in Navision after an event (A button Click), after a specific time period, say 30 seconds. can it be done?

Thanks

Xavi

Comments

  • WaldoWaldo Member Posts: 3,412
    First put a SLEEP(30000) (or was it 300000?), then call your function.

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • kinekine Member Posts: 12,562
    Use Automation Navision Timer... you will get new event - AutomVariable::OnTimer. On the variable you can set interval and enable - disable the timer...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • GoMaDGoMaD Member Posts: 313
    To get the events on a variable linked to an automation server (like kine said) you should adjust the variable property 'WithEvents' to yes.

    Then you will see some new triggers on the bottom of your C/AL window where you can add the necessary code.
    Now, let's see what we can see.
    ...
    Everybody on-line.
    ...
    Looking good!
  • WaldoWaldo Member Posts: 3,412
    Do you want to use a 30-second interval, or just a one-time-30-second-time ... (if you know what I mean)?

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • XaviXavi Member Posts: 26
    I want to call the function only once after 30 seconds. I managed to do it with Navision Timer 1.0. So, is it possible only with Automation? Thanks

    Xavi
  • kinekine Member Posts: 12,562
    Yes and No... I think that it is easy and more "clean" to do it with automation. But you can use form OnTimer event to do it. But there is problem, that you are not able to disable/enable this timer in run-time. It must be enabled in form properties and enablin/disabling must be done through some condition in the trigger (IF TimerEnabled then ...)...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • WaldoWaldo Member Posts: 3,412
    Guys, really, please explain, why not using the SLEEP()-statement?

    What is unclean about that???

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • kinekine Member Posts: 12,562
    Because if you use SLeep, the form is still blocked and there is opened transaction. If you use Timer, you can still work and you are not blocking other users if you started some transaction before... :whistle:
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • WaldoWaldo Member Posts: 3,412
    Ah ... did not think of that ](*,)

    And off course, when during a 30 second interval ... one would want to work ...

    OK, my mistake ... :oops:

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
Sign In or Register to comment.