Esempio n. 1
0
        public void UnsubscribeToParserEvents()
        {
            CheckDisposed();

            m_clientTaskReportHandler = null;
            if (m_scheduler != null)
            {
                //first, we remove our own event handlers
                m_scheduler.AttemptToPause();
                if (m_scheduler.IsPaused)
                {
#if IsThisNeeded
                    // This is not what we want: it will also disable the handlers that report the progress in the main app status bar
                    m_scheduler.ParserUpdateVerbose -= ParserUpdateHandlerForPolling;
                    m_scheduler.ParserUpdateNormal  -= ParserUpdateHandlerForPolling;
#endif

                    if (m_localTaskReportHandler != null)
                    {
                        m_scheduler.ParserUpdateVerbose -= m_localTaskReportHandler;
                        m_scheduler.ParserUpdateNormal  -= m_localTaskReportHandler;
                        m_localTaskReportHandler         = null;
                    }
                }
                m_scheduler.Resume();
            }
        }
Esempio n. 2
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)
        {
            //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
            // Must not be run more than once.
            if (m_isDisposed)
            {
                return;
            }

            m_clientTaskReportHandler = null;

            if (disposing)
            {
                // Dispose managed resources here.
                if (m_scheduler != null)
                {
                    /* Don't know why it tries this, since the Dispose method in the scheduler calls Resume().
                     * m_scheduler.AttemptToPause();
                     * while (!m_scheduler.IsPaused)
                     * {
                     *      // How long should we wait?
                     *      // Or, should we put up a pacifier to let the user knwo we are trying to shut down the parser/
                     * }
                     */

                    // Remove event handlers.
                    m_scheduler.ParserUpdateVerbose -= ParserUpdateHandlerForPolling;
                    m_scheduler.ParserUpdateNormal  -= ParserUpdateHandlerForPolling;
                    if (m_localTaskReportHandler != null)
                    {
                        m_scheduler.ParserUpdateVerbose -= m_localTaskReportHandler;
                        m_scheduler.ParserUpdateNormal  -= m_localTaskReportHandler;
                    }
                    ParserFactory.ReleaseScheduler(m_scheduler);                     // ReleaseScheduler calls Dispose on m_scheduler.
                }
            }

            // Dispose unmanaged resources here, whether disposing is true or false.
            m_localTaskReportHandler = null;
            m_scheduler           = null;
            m_currentError        = null;
            m_activity            = null;
            TraceResult           = null;
            m_notificationMessage = null;

            m_isDisposed = true;
        }
Esempio n. 3
0
        /// <summary>
        /// This will cause a handler to be invoked, in the client's thread,
        /// for all events that the parser produces.
        /// </summary>
        /// <param name="handler"></param>
        public void SubscribeToParserEvents(bool verbose, ParserUpdateEventHandler handler)
        {
            CheckDisposed();

            //we don't directly wire up the parser to the client's handler.
            //instead, we wire up a local handler which general another job of
            //safely calling the clients Handler, which will be in a different thread at that point.

            Debug.Assert(handler.Target is System.Windows.Forms.Control, "Currently, you can only subscribe with a Windows forms control.");
            Debug.Assert(m_localTaskReportHandler == null, "You need to unsubscribe before subscribing again.");
            m_localTaskReportHandler  = ParserUpdateHandler;
            m_clientTaskReportHandler = handler;

            if (verbose)
            {
                m_scheduler.ParserUpdateVerbose += m_localTaskReportHandler;
            }
            else
            {
                m_scheduler.ParserUpdateNormal += m_localTaskReportHandler;
            }
        }
Esempio n. 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)
		{
			//Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
			// Must not be run more than once.
			if (m_isDisposed)
				return;

			m_clientTaskReportHandler = null;

			if (disposing)
			{
				// Dispose managed resources here.
				if (m_scheduler != null)
				{
					/* Don't know why it tries this, since the Dispose method in the scheduler calls Resume().
					m_scheduler.AttemptToPause();
					while (!m_scheduler.IsPaused)
					{
						// How long should we wait?
						// Or, should we put up a pacifier to let the user knwo we are trying to shut down the parser/
					}
					*/

					// Remove event handlers.
					m_scheduler.ParserUpdateVerbose -= ParserUpdateHandlerForPolling;
					m_scheduler.ParserUpdateNormal -= ParserUpdateHandlerForPolling;
					if (m_localTaskReportHandler != null)
					{
						m_scheduler.ParserUpdateVerbose -= m_localTaskReportHandler;
						m_scheduler.ParserUpdateNormal -= m_localTaskReportHandler;
					}
					ParserFactory.ReleaseScheduler(m_scheduler); // ReleaseScheduler calls Dispose on m_scheduler.
				}
			}

			// Dispose unmanaged resources here, whether disposing is true or false.
			m_localTaskReportHandler = null;
			m_scheduler = null;
			m_currentError = null;
			m_activity = null;
			TraceResult = null;
			m_notificationMessage = null;

			m_isDisposed = true;
		}
Esempio n. 5
0
		public void UnsubscribeToParserEvents()
		{
			CheckDisposed();

			m_clientTaskReportHandler = null;
			if (m_scheduler != null)
			{
				//first, we remove our own event handlers
				m_scheduler.AttemptToPause();
				if (m_scheduler.IsPaused)
				{
#if IsThisNeeded
					// This is not what we want: it will also disable the handlers that report the progress in the main app status bar
					m_scheduler.ParserUpdateVerbose -= ParserUpdateHandlerForPolling;
					m_scheduler.ParserUpdateNormal -= ParserUpdateHandlerForPolling;
#endif

					if (m_localTaskReportHandler != null)
					{
						m_scheduler.ParserUpdateVerbose -= m_localTaskReportHandler;
						m_scheduler.ParserUpdateNormal -= m_localTaskReportHandler;
						m_localTaskReportHandler = null;
					}
				}
				m_scheduler.Resume();
			}
		}
Esempio n. 6
0
		/// <summary>
		/// This will cause a handler to be invoked, in the client's thread,
		/// for all events that the parser produces.
		/// </summary>
		/// <param name="handler"></param>
		public void SubscribeToParserEvents(bool verbose, ParserUpdateEventHandler handler)
		{
			CheckDisposed();

			//we don't directly wire up the parser to the client's handler.
			//instead, we wire up a local handler which general another job of
			//safely calling the clients Handler, which will be in a different thread at that point.

			Debug.Assert(handler.Target is System.Windows.Forms.Control,"Currently, you can only subscribe with a Windows forms control.");
			Debug.Assert(m_localTaskReportHandler == null, "You need to unsubscribe before subscribing again.");
			m_localTaskReportHandler = ParserUpdateHandler;
			m_clientTaskReportHandler = handler;

			if (verbose)
				m_scheduler.ParserUpdateVerbose += m_localTaskReportHandler;
			else
				m_scheduler.ParserUpdateNormal += m_localTaskReportHandler;
		}