Using Vision Commands with Multitasking

You can execute vision sequences and retrieve results in more than one task in SPEL+. SPEL+ automatically handles executing one vision command at a time internally. When multiple tasks require the vision system, the commands are executed on a first come first serve basis. While one task is using the vision system, the other tasks will block (wait) for the first task to finish the current vision command.
In some cases, you may be running the same sequence from different tasks using different cameras. You will want to run the sequence and get the results in one task while other tasks wait. Use the SyncLock and SyncUnlock commands to lock the vision system for one task, then release it for others.

Function VisionTask(camera As Integer)  
  Boolean found  
  Do  
    SyncLock 1 ' Lock vision just for this task  
    VSet FindParts.Camera, camera  
    VRun FindParts  
    VGet FindParts.AllFound, found  
    SyncUnlock 1 ' Unlock vision for other tasks  
  Loop  
Fend