The Payment Selector supports single processes with multiple threads and multiple processes with one or more threads. During the Add, Modify, and Delete functions, mutexes in the Payment Selector permit only one thread at a time to modify data. Each component is required to share its data among both multiple threads within a single process and multiple processes. Modifications using one instance of the control must be reflected in all instances. The SDK sample uses shared global memory to implement this requirement. You must ensure that multiple instances of the Create function are thread safe.
The SDK sample uses the following elements to ensure thread safety:
The MFC CWinApp class captures and transforms the first thread into an MFC thread in the component data structure when the DLL is loaded. The SDK files thrdwrap.cpp and thrdchk.h create the necessary threading structures within MFC to make MFC thread safe within a single process, independent of the shared global data structure. The thrdwrap.cpp file, which includes the thrdwrap.h header file, implements a thread class and checks thread routines to ensure that MFC has the necessary information to perform thread-safe processes. The thrdchk.h header file defines the entry points to the current thread to check whether or not it exists.
Although the majority of multiple-thread and multiple-process support occurs in the Payment Selector, you must provide a mutex for the Create function to ensure that new instances of the component are created in a thread-safe manner.
Note Do not modify the sample files thrdwrap.cpp and thrdchk.h, because these files support thread-safe processes in MFC.
See the Win32 Programmer's Reference for additional information on creating a mutex.