Exemplo n.º 1
0
        /// <summary>
        /// Initialize this object as a DicomThread with no parent thread.
        /// </summary>
        /// <param name="threadManager">The threadManager.</param>
        public new void Initialize(ThreadManager threadManager)
        {
            // Initialize may only be called once, so check for this.
            if (this.isInitialized)
            {
                throw new HliException(alreadyInitializedErrorText);
            }

            base.Initialize(threadManager);
            this.dvtkScriptSession = new Dvtk.Sessions.ScriptSession();
            Initialize();
            this.isInitialized = true;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Code that normally would be present in the constructor.
        /// This code is however put in a separate method to be able to have only
        /// one constructor in DicomThread. This way, it is easier to derive from a
        /// DicomThread class.
        /// 
        /// Use this method if this threads should not have a parent thread.
        /// </summary>
        /// <param name="threadManager">The ThreadManager that manages this object.</param>
        protected void Initialize(ThreadManager threadManager)
        {
            this.parent = null;
            this.dotNetThread = new System.Threading.Thread(new System.Threading.ThreadStart(this.ThreadEntryPoint));
            this.threadManager = threadManager;
            this.commonThreadLock = this.threadManager.CommonThreadLock;
            this.childs = new ThreadCollection(this.commonThreadLock);
            this.topmostThread = this;

            lock(this.commonThreadLock)
            {
                this.threadManager.Childs.Add(this);
                this.threadManager.Threads.Add(this);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes this instance.
        /// </summary>
        /// <remarks>
        /// Call one of the Initialize methods directly after creating a Thread instance.
        /// 
        /// Code that normally would be present in the constructor.
        /// This code is however put in a separate method to be able to have only
        /// one constructor in DicomThread. This way, it is easier to derive from a
        /// DicomThread class.
        /// 
        /// Use this method if this threads should not have a parent thread.
        /// </remarks>
        /// <param name="threadManager">The ThreadManager that manages this object.</param>
        protected void Initialize(ThreadManager threadManager)
        {
            this.parent = null;
            this.dotNetThread = new System.Threading.Thread(new System.Threading.ThreadStart(this.ThreadEntryPoint));
            this.threadManager = threadManager;
            this.topmostThread = this;

            // See property ThreadManagerLock when to use this lock.
            lock (this.threadManager.ThreadManagerLock)
            {
                this.childs = new ThreadCollection();
                this.threadManager.ChildThreads.Add(this);
                this.threadManager.AddChildThread(this);
            }
        }
Exemplo n.º 4
0
        //
        // - Methods -
        //
        /// <summary>
        /// Code that normally would be present in the constructor.
        /// This code is however put in a separate method to be able to have only
        /// one constructor in DicomThread. This way, it is easier to derive from a
        /// DicomThread class.
        /// 
        /// Use this method if this object should have a parent thread.
        /// </summary>
        /// <param name="parent">The parent Thread.</param>
        protected void Initialize(Thread parent)
        {
            this.parent = parent;
            this.dotNetThread = new System.Threading.Thread(new System.Threading.ThreadStart(this.ThreadEntryPoint));
            this.threadManager = this.parent.ThreadManager;
            this.commonThreadLock = this.threadManager.CommonThreadLock;
            this.childs = new ThreadCollection(this.commonThreadLock);
            this.topmostThread = this.parent.TopmostThread;

            lock(this.commonThreadLock)
            {
                this.parent.childs.Add(this);
                this.parent.ThreadManager.Threads.Add(this);
            }

            if (this.parent.Options.AttachChildsToUserInterfaces)
            {
                foreach(UserInterface userInterface in this.parent.AttachedUserInterfaces)
                {
                    userInterface.Attach(this);
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Initializes this instance.
        /// </summary>
        /// <remarks>
        /// Call one of the Initialize methods directly after creating a Thread instance.
        /// 
        /// Code that normally would be present in the constructor.
        /// This code is however put in a separate method to be able to have only
        /// one constructor in DicomThread. This way, it is easier to derive from a
        /// DicomThread class.
        /// 
        /// Use this method if this object should have a parent thread.
        /// </remarks>
        /// <param name="parent">The parent Thread.</param>
        protected void Initialize(Thread parent)
        {
            this.parent = parent;
            this.dotNetThread = new System.Threading.Thread(new System.Threading.ThreadStart(this.ThreadEntryPoint));
            this.threadManager = this.parent.ThreadManager;
            this.topmostThread = this.parent.TopmostThread;

            // See property ThreadManagerLock when to use this lock.
            lock (this.threadManager.ThreadManagerLock)
            {
                this.childs = new ThreadCollection();
                this.parent.childs.Add(this);
                this.threadManager.AddThread(this);
            }

            if (this.parent.ThreadOptions.AttachChildsToUserInterfaces)
            {
                foreach (IThreadUserInterface threadUserInterface in this.parent.AttachedUserInterfaces)
                {
                    threadUserInterface.Attach(this);
                }
            }
        }