示例#1
0
        /// <summary>
        /// Executes in two distinct scenarios.
        ///
        /// 1. If disposing is true, the method has been called directly
        /// or indirectly by a user's code via the Dispose method.
        /// Both managed and unmanaged resources can be disposed.
        ///
        /// 2. If disposing is false, the method has been called by the
        /// runtime from inside the finalizer and you should not reference (access)
        /// other managed objects, as they already have been garbage collected.
        /// Only unmanaged resources can be disposed.
        /// </summary>
        /// <param name="disposing"></param>
        /// <remarks>
        /// If any exceptions are thrown, that is fine.
        /// If the method is being done in a finalizer, it will be ignored.
        /// If it is thrown by client code calling Dispose,
        /// it needs to be handled by fixing the bug.
        ///
        /// If subclasses override this method, they should call the base implementation.
        /// </remarks>
        private void Dispose(bool disposing)
        {
            System.Diagnostics.Debug.WriteLineIf(!disposing, "****** Missing Dispose() call for " + GetType().Name + ". ****** ");
            // Must not be run more than once.
            if (m_isDisposed)
            {
                return;
            }

            if (disposing)
            {
                if (m_messages != null)
                {
                    while (m_messages.Count > 0)
                    {
                        m_messages.Remove();
                    }
                }
            }

            // Dispose unmanaged resources here, whether disposing is true or false.
            m_master   = null;
            m_receiver = null;
            m_messages = null;

            m_isDisposed = true;
        }
示例#2
0
		private int m_cLevelsOfSequentialBlockInMessageHandler; // See Begin/EndSequentialBlock.

		/// <summary>
		/// Make one.
		/// </summary>
		/// <param name="master"></param>
		public MessageSequencer(Control master)
		{
			if (master.IsDisposed)
				throw new ArgumentException(String.Format("MessageSequencer cannot use a disposed Control: {0}", master.ToString()));

			m_master = master;
			m_receiver = m_master as IReceiveSequentialMessages;
			if (m_receiver == null)
				throw new Exception("Master control for MessageSequencer must implement IReceiveSequentialMessages");
			if (msgs == null)
				CreateSet();
		}
示例#3
0
        private int m_cLevelsOfSequentialBlockInMessageHandler;         // See Begin/EndSequentialBlock.

        /// <summary>
        /// Make one.
        /// </summary>
        /// <param name="master"></param>
        public MessageSequencer(Control master)
        {
            if (master.IsDisposed)
            {
                throw new ArgumentException(String.Format("MessageSequencer cannot use a disposed Control: {0}", master.ToString()));
            }

            m_master   = master;
            m_receiver = m_master as IReceiveSequentialMessages;
            if (m_receiver == null)
            {
                throw new Exception("Master control for MessageSequencer must implement IReceiveSequentialMessages");
            }
            if (msgs == null)
            {
                CreateSet();
            }
        }
示例#4
0
        /// <summary>
        /// Executes in two distinct scenarios.
        ///
        /// 1. If disposing is true, the method has been called directly
        /// or indirectly by a user's code via the Dispose method.
        /// Both managed and unmanaged resources can be disposed.
        ///
        /// 2. If disposing is false, the method has been called by the
        /// runtime from inside the finalizer and you should not reference (access)
        /// other managed objects, as they already have been garbage collected.
        /// Only unmanaged resources can be disposed.
        /// </summary>
        /// <param name="disposing"></param>
        /// <remarks>
        /// If any exceptions are thrown, that is fine.
        /// If the method is being done in a finalizer, it will be ignored.
        /// If it is thrown by client code calling Dispose,
        /// it needs to be handled by fixing the bug.
        ///
        /// If subclasses override this method, they should call the base implementation.
        /// </remarks>
        private void Dispose(bool disposing)
        {
            System.Diagnostics.Debug.WriteLineIf(!disposing, "****** Missing Dispose() call for " + GetType().Name + ". ****** ");
            // Must not be run more than once.
            if (m_isDisposed)
                return;

            if (disposing)
            {
                if (m_messages != null)
                {
                    while (m_messages.Count > 0)
                        m_messages.Remove();
                }
            }

            // Dispose unmanaged resources here, whether disposing is true or false.
            m_master = null;
            m_receiver = null;
            m_messages = null;

            m_isDisposed = true;
        }