Multithreaded programs
The .NET runtime environment is inherently multithreaded. IBM MQ classes for .NET allows a queue manager object to be shared across multiple threads but ensures that all access to the target queue manager is synchronized.
Consider a simple program that connects to a queue manager and opens a queue at startup. The program displays a single button on the screen. When a user clicks that button, the program fetches a message from the queue. In this situation, the application initialization occurs in one thread, and the code that executes in response to the button press executes in a separate thread (the user interface thread).
The implementation of IBM MQ .NET ensures that, for a particular connection (MQQueueManager object instance), all access to the target IBM MQ queue manager is synchronized. The default behavior is that a thread that wants to issue a call to a queue manager is blocked until all other calls in progress for that connection are complete. If you require simultaneous access to the same queue manager from multiple threads within your program, create a new MQQueueManager object for each thread that requires concurrent access. (This is equivalent to issuing a separate MQCONN call for each thread.)
If the default connection options are overridden by MQC.MQCNO_HANDLE_SHARE_NONE or MQC.MQCNO_SHARE_NO_BLOCK then the queue manager is no longer synchronized.
Parent topic: Writing and deploying IBM MQ .NET programs