difference between Taskcreate and Taskcreatesync

  • Hello,

    I wanted to know the difference between usage of taskcreate and Taskcreatesync in Val3. I went through the val3 documentation but couldn't understand how both varies when we use it in a Val3 application. It would be better if an example could be provided.

    Thank you

  • Place your Ad here!
  • Hi Rahul,

    In a few words :

    TaskCreate : Task is executed "continuously" depending on the given priority level.

    TaskCreateSync : Task is executed every x.xx second. Priority level is 3000 (factory setting, can't be modified).

    Example :

    TaskCreate "MyTask",50,ExecuteATask()

    --> Function ExecuteATask() is executed once, with a priority of 50. You can have an infinite loop in your function.

    TaskCreateSync "MyTaskSync",0.5,bOverrun,ExecuteASyncTask()

    --> Function ExecuteASyncTask() is executed every 0.5 second.

    bOverrun=true : function is executed to the end, even if it takes more than 0.5s

    bOverrun=false : function is killed if not completed after 0.5s

    NEVER use infinite loop in such a function, otherwise your CPU will run out of resource.

    Hope this helps,


  • Thank you for the reply

    when I used the TaskCreate and ran the function, It showed invalid task name

    TaskCreate sFilling,10,Task()

    This was the code I used but it showed invalid task name

    Edit: I tried using a normal string instead of using a string variable and it worked. Thank you for your help

  • I couldn't say better.

    Just adding some more recomendation about TaskCreateSync, please keep it simple and small. As Jeff said, your CPU will run out of resources.

    Also, you are only allowed to have 2 sync tasks simultaneously, I would say 99% percent of the time you don't need a sync task, normal tasks are fast and reliable enough.

  • Be carreful that the structure of taskCreate and taskCreateSync are not the same :

    taskCreate sName, nPriority, program()

    taskCreateSync sName, nPeriod, bOverrun, program()

    If you don't use good parameters the line is invalid !

    Other thing :, be carreful of uppecase and lowercase of the key words and variable. In Val3 program, you need to respect everytime the script.

    Try le line :

    taskCreate sFilling,10,Task()

    Edited once, last by Galet ().

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account
Sign up for a new account in our community. It's easy!
Register a new account
Sign in
Already have an account? Sign in here.
Sign in Now

Advertising from our partners