Example threaded script - counter

This example threaded script will display a message on the control surface of the Live Python block that updates every second.

while (1):
    message.string_set("Counter: "+str(state))		
    state = state +1
    event.wait(1000)	

The counter will start as soon as the project is emulated or deployed, it does not require any values to be received on the inputs.

Note: Threading must be enabled on the Device Properties of the Live Python block. It is not supported by default. If it is not enabled, when the project is run, the message RuntimeError : exit thread... will be displayed in the Message field.

See also

Syntax and structure of a threaded script

Example threaded script - power up mute delay