I have a DICOM SCP that runs as a Windows Service that I would like to gracefully shutdown in response to the Service Control Manager's Stop command. I know I can call DicomServer.StopListening() to stop listening for new associations, but I still need to deal with any open associations. Ideally I would let any open associations complete, but an SCU could keep the association open indefinitely so I still need a timeout mechanism to abort associations still open after a given timeout.
So a few questions:
1) Any feedback, tips or ideas on how to best do this?
2) To abort open associations, I need to enumerate them. I didn't find any central list that CC keeps of open associations so I think I need to manage that myself. My plan is to add the DicomServer to a list every time a new association is created and hook the NetworkClosed event so I can remove it when it is done. Is there a cleaner or easier way than this?
3) How does the CC ImageServer handle this? I looked through the code and couldn't find any references to shutting down open associations.
Thanks!
Chris