Saving and Restoring Multithread SettingsCognex VisionPro 9.21

A CogJobManager supports API that allows you to record and restore the global vision-tool multithreading settings stored in a CogVisionToolMultiThreading object.

See the following sections for more information:

Global Multithreading Settings

Use a CogVisionToolMultiThreading object to set global multithreading settings in your vision application. The CogVisionToolMultiThreading class supports the following properties:

  • Enable: Enables/disables vision tool mulithreading for this application.
  • ThreadCount: Sets the number of threads the multithreading mechanism uses when running vision tools.
  • ThreadCountMode: Sets whether multithreaded aware vision tools use as many thread as there are processor cores or whether the user specifies the number of threads.

Similarly, any CogJobManager you use in your vision application supports the following static properties:

Modifying any of these static properties in a CogJobManager automatically sets the corresponding property in the CogVisionToolMultiThreading object.

Saving the Current Settings

A CogJobManager supports the PersistedApplicationState property (of type CogApplicationState) to store the current settings for vision-tool multithreading.

Each time the CogJobManager is serialized to a file, it uses the ReadMultiThreadingApplicationState method to record the multithreading settings in the following properties:

Regardless of how global multithreading settings might be modified in CogVisionToolMultiThreading later, each CogJobManager retains its own record of the settings as it is saved.

Restoring the Current Settings

Each CogJobManager uses its PersistedApplicationState to store the application-level settings for vision-tool multithreading when it was last serialized.

In some environments the application-level settings might be different than a deserialized CogJobManager. If you need to restore the saved multithreading settings from a CogJobManager to the global CogVisionToolMultiThreading settings, use the ApplyMultiThreadingApplicationState method.

The ApplyMultiThreadingApplicationState method makes the global multithreading state of the current application equivalent to the values in the multithreading properties of PersistedApplicationState of this CogJobManager.