/// <summary> /// Create and start a child DicomThread. /// </summary> /// <param name="overviewThread">The overview Thread.</param> private void CreateAndStartChildDicomThread(ConcurrentMessageIterator overviewThread) { ConcurrentMessageIterator childDicomThread = null; if (overviewThread.resultsFileNameOnlyWithoutExtensionBasisChildThreads == null) { // Create a new child DicomThread. Type[] types = new Type[1]; types[0] = typeof(String); ConstructorInfo constructorInfo = overviewThread.GetType().GetConstructor(types); Object[] constructorArguments = new Object[1]; constructorArguments[0] = overviewThread.identifierBasisChildThreads; childDicomThread = constructorInfo.Invoke(constructorArguments) as ConcurrentMessageIterator; } else { // Create a new child DicomThread. Type[] types = new Type[2]; types[0] = typeof(String); types[1] = typeof(String); ConstructorInfo constructorInfo = overviewThread.GetType().GetConstructor(types); Object[] constructorArguments = new Object[2]; constructorArguments[0] = overviewThread.identifierBasisChildThreads; constructorArguments[1] = overviewThread.resultsFileNameOnlyWithoutExtensionBasisChildThreads; childDicomThread = constructorInfo.Invoke(constructorArguments) as ConcurrentMessageIterator; } // The new sub threads must become a child of the overview Thread. childDicomThread.Initialize(overviewThread); childDicomThread.inboundDicomMessageFilters.AddRange(overviewThread.inboundDicomMessageFilters); childDicomThread.outboundDicomMessageFilters.AddRange(overviewThread.outboundDicomMessageFilters); childDicomThread.overviewThread = overviewThread; // Copy all options from the overview Thread. childDicomThread.Options.DeepCopyFrom(overviewThread.Options); // Set the correct identifier for the new sub thread. lock (this.lockObject) { childDicomThread.Options.Identifier = this.identifierBasisChildThreads + overviewThread.childDicomThreadNumber.ToString(); if (overviewThread.resultsFileNameOnlyWithoutExtensionBasisChildThreads != null) { childDicomThread.Options.ResultsFileNameOnlyWithoutExtension = overviewThread.resultsFileNameOnlyWithoutExtensionBasisChildThreads + overviewThread.childDicomThreadNumber.ToString(); } overviewThread.childDicomThreadNumber++; } // Copy all handlers from the overview Thread. foreach (MessageHandler messageHandler in overviewThread.MessagesHandlers) { childDicomThread.AddToFront(messageHandler); } // Make sure that only one association is handled by a child DicomThread. childDicomThread.MessageReceivedEvent += new MessageReceivedEventHandler(childDicomThread.HandleMessageReceivedEvent); childDicomThread.SendingMessageEvent += new SendingMessageEventHandler(childDicomThread.HandleSendingMessageEvent); // Start the new sub DicomThread. childDicomThread.Start(); }