예제 #1
0
        /// <summary>
        /// Create and start a sub DicomThread.
        /// </summary>
        /// <param name="overviewThread">The overview Thread.</param>
        internal void CreateAndStartChildDicomThread(ConcurrentSCP overviewThread)
        {
            // Create a new sub DicomThread.
            Type[] types = new Type[0];

            ConstructorInfo constructorInfo = overviewThread.GetType().GetConstructor(types);

            ConcurrentSCP subDicomThread = constructorInfo.Invoke(null) as ConcurrentSCP;

            // The new sub threads must become a child of the overview Thread.
            subDicomThread.Initialize(overviewThread);

            subDicomThread.inboundDicomMessageFilters.AddRange(overviewThread.inboundDicomMessageFilters);
            subDicomThread.outboundDicomMessageFilters.AddRange(overviewThread.outboundDicomMessageFilters);

            subDicomThread.overviewThread = overviewThread;

            // Copy all options from the overview Thread.
            subDicomThread.Options.DeepCopyFrom(overviewThread.Options);

            // Set the correct identifier for the new sub thread.
            lock(this.lockObject)
            {
                subDicomThread.Options.Identifier = overviewThread.Options.Identifier + "_SubDicomThread" + overviewThread.subDicomThreadNumber.ToString();
                overviewThread.subDicomThreadNumber++;
            }

            // Copy all handlers from the overview Thread.
            foreach(MessageHandler messageHandler in overviewThread.MessagesHandlers)
            {
                subDicomThread.AddToFront(messageHandler);
            }

            subDicomThread.AssociationReleasedEvent+= new AssociationReleasedEventHandler(HandleChildAssociationReleasedEvent);

            // Start the new sub DicomThread.
            subDicomThread.Start();
        }