Potential deadlock situations

The IPRO is a highly multi-threaded architecture. It boosts performance on multi-processor, multi-core and multi-threaded systems. However, because it also massively overlays the Windows messaging architecture, that has limitations in multi-threaded environments, it can cause deadlock situations. You can find a set of hints below about how to avoid deadlock scenarios when using IPRO, and optionally the MediumWeight Visuals.

How to use IPRO and the MediumWeight Visuals in a safe way:

  • Avoid calling back to IPRO in event handlers. Many IPRO events receive IPRO object references. If it is really important, use the received object reference to query basic properties, but never initiate massive processing which causes hard IPRO usage or additional event firing, even in different threading context.

  • Avoid calling the SendMessage API targeting windows that were created in different threads. Never send messages from a worker thread to a window, which was created in the main UI thread. This is a typical reason of deadlocks in multi-threaded windows applications even without any IPRO, or other COM object usage.

  • Avoid accessing objects that were created in a particular thread from a different thread. If possible, encapsulate all steps to create and process IPRO related objects into a single thread, or ensure proper interface marshalling if multiple thread usage is necessary and you need to access objects in a thread different than the creator.

  • Ensure that during an IPRO call the program does not enter into another parallel call. This can happen, for example, if you have a UI button associated with some process and click it a second time before the process initiated by the first click has finished. The IPRO Workflow manager has its own message loop to enable the UI of the integrator application to be responsive and painted correctly, so this type of encapsulation is possible. Disable the related UI elements during any processing so that the user cannot click the button at the wrong time even if the interface is responsive.