Page 1 of 1

Scheduled task

Posted: Mon May 26, 2014 5:30 am
by bjornidar
Hi,

is it possible to run a scheduled task every second in iX?

Re: Scheduled task

Posted: Wed Jul 30, 2014 9:13 am
by Kyle W.
There are a couple options for scheduling a task. The first doesn't require any scripting. You could add the Demo Controller as an additional controller, which has counters built into it. See screenshots 1 and 2. You can set the timer to a tag and give the tag an action to do something every time the value of the timer changes.

A second option involves scripting but doesn't require a second controller. You can instantiate a timer with an interval and have it execute code every time the timer event "clicks". See the sample code:

Code: Select all

//Tie the start of the timer to an event like screen open or tag value change
		void Screen1_Opened(System.Object sender, System.EventArgs e)
		{
			m_Timer = new Timer();
			m_Timer.Interval = 500;
			m_Timer.Tick += doSomething;
			m_Timer.Enabled = true;
		}
			
		void doSomething (object sender, EventArgs e)
		{
			//code to execute on each timer tick
		}