The version of APINGD provided in the sample code illustrates how to achieve nonqueued behavior from an invokable TP in Windows NT or Windows 95. This means that multiple copies of APING can talk to the same copy of APINGD at the same time. However, you cannot run multiple copies of an Windows NT service. The features are achieved by always having a thread with an Accept_Conversation outstanding, so that any incoming attach for APINGD will always be satisfied immediately.
Setup requirements are the same as for the single-threaded version. Note that the remote LU and mode used should support parallel sessions so that more than one conversation at a time is possible.
These are the same as for the single-threaded version.
Operation is similar to that of the single-threaded version. The same three routines are used (main, ServiceMain and ControlHandler). ServiceMain calls the TPStart routine. This routine must not return until the service is ready to terminate.
The TPStart routine does some initialization, creates the first conversation thread, and then waits on an event created by the ServiceMain routine. This event is set when the service control manager issues an order to STOP or SHUTDOWN. When the event is set, it calls WinCPICCleanup, which will cancel any active conversations and return outstanding Accept_Conversation calls, thus making all conversation threads exit. It then marks the service as STOPPED.
The ThreadStart routine is the entry point for each of the conversation threads. It issues Accept_Conversation and Wait_For_Conversation, and when this completes, it creates another thread to wait for the next attach while the existing thread services the first attach.