/// <summary>
        /// Fires the ProgressChanged event.
        /// </summary>
        /// <remarks><para>If the control parameter was given in the constructor of the class, the
        /// event is fired in the context of the calling thread and not of the worker thread.</para></remarks>
        protected virtual void OnProgressChanged()
        {
            //if (m_state == ILAlgorithmState.Unloaded) return;
            ILAlgorithmEventArgs evargs;

            if (String.IsNullOrEmpty(m_lastMessage))
            {
                evargs = new ILAlgorithmEventArgs(m_progress, "Progress: " + ((int)(m_progress * 100)) + "%", m_state);
            }
            else
            {
                evargs = new ILAlgorithmEventArgs(m_progress, m_lastMessage, m_state);
            }
            if (m_control != null && m_control.InvokeRequired && ProgressChanged != null)
            {
                if (!m_control.Disposing && !m_control.IsDisposed && ProgressChanged != null)
                {
                    m_control.Invoke(ProgressChanged, this, evargs);
                }
            }
            else
            {
                if (ProgressChanged != null)
                {
                    ProgressChanged(this, evargs);
                }
            }
        }
示例#2
0
        /// <summary>
        /// helper function firing the progress changed event
        /// </summary>
        /// <param name="message">string to be send within the
        /// <see cref="ILNumerics.Algorithms.ILAlgorithmEventArgs"/> </param>
        /// <returns>false if a handler of the event has attempted to cancel the
        /// operation, true if the algorithm should continue normaly.</returns>
        protected virtual bool OnProgressChanged(string message)
        {
            ILAlgorithmEventArgs e = new ILAlgorithmEventArgs(m_progress, "Progress:" + message, m_state);

            if (ProgressChanged != null)
            {
                ProgressChanged(this, e);
            }
            if (e.Cancel == true)
            {
                return(false);
            }
            return(true);
        }
示例#3
0
        /// <summary>
        /// helper function firing the state changed event
        /// </summary>
        /// <param name="message">string to be send within the
        /// <see cref="ILNumerics.Algorithms.ILAlgorithmEventArgs"/> </param>
        /// <returns>false if a handler of the event has attempted to cancel the
        /// operation, true if the algorithm should continue normaly.</returns>
        protected virtual bool OnStateChanged(string message)
        {
            ILAlgorithmEventArgs e = new ILAlgorithmEventArgs(m_progress, "State:" + message, m_state);

            if (StateChanged != null)
            {
                StateChanged(this, e);
            }
            if (e.Cancel == true)
            {
                SetState(ILAlgorithmState.Canceled);
                return(false);
            }
            return(true);
        }
        /// <summary>
        /// Fires the StateChanged event.
        /// </summary>
        /// <remarks><para>If the control parameter was given in the constructor of the class, the
        /// event is fired in the context of the calling thread and not of the worker thread.</para></remarks>
        protected virtual void OnStateChanged()
        {
            ILAlgorithmEventArgs evargs = new ILAlgorithmEventArgs(m_progress, "State: " + m_state.ToString(), m_state);

            if (m_control != null && m_control.InvokeRequired)
            {
                if (!m_control.Disposing && !m_control.IsDisposed && StateChanged != null)
                {
                    m_control.Invoke(StateChanged, this, evargs);
                }
            }
            else
            {
                if (StateChanged != null)
                {
                    StateChanged(this, evargs);
                }
            }
        }
示例#5
0
 void bsortConstant_StateChanged(object sender, ILAlgorithmEventArgs e) {
     if (m_stopwatch == null) {
         m_stopwatch = new System.Diagnostics.Stopwatch(); 
     }
     switch (e.State) {
         case ILAlgorithmState.Running: 
             m_stopwatch.Reset(); 
             m_stopwatch.Start();
             break; 
         case ILAlgorithmState.Finished:
             m_stopwatch.Stop(); 
             Info("Last operation finished in: " + m_stopwatch.ElapsedMilliseconds + " ms" + Environment.NewLine); 
             break;
         default: 
             m_stopwatch.Stop(); 
             break; 
     }
 }
示例#6
0
 /// <summary>
 /// Fires the ProgressChanged event.
 /// </summary>
 /// <remarks><para>If the control parameter was given in the constructor of the class, the 
 /// event is fired in the context of the calling thread and not of the worker thread.</para></remarks>
 protected virtual void OnProgressChanged () {
     //if (m_state == ILAlgorithmState.Unloaded) return; 
     ILAlgorithmEventArgs evargs; 
     if (String.IsNullOrEmpty(m_lastMessage))
         evargs = new ILAlgorithmEventArgs(m_progress,"Progress: " + ((int)(m_progress * 100)) + "%", m_state);
     else 
         evargs = new ILAlgorithmEventArgs(m_progress,m_lastMessage, m_state);
     if (m_control != null && m_control.InvokeRequired && ProgressChanged != null) {
         if (!m_control.Disposing && !m_control.IsDisposed && ProgressChanged != null) {
             m_control.Invoke(ProgressChanged,this, evargs);
         }
     } else {
         if (ProgressChanged != null)
             ProgressChanged(this, evargs); 
     }
 }
示例#7
0
 /// <summary>
 /// Fires the StateChanged event.
 /// </summary>
 /// <remarks><para>If the control parameter was given in the constructor of the class, the 
 /// event is fired in the context of the calling thread and not of the worker thread.</para></remarks>
 protected virtual void OnStateChanged () {
     ILAlgorithmEventArgs evargs = new ILAlgorithmEventArgs(m_progress,"State: " + m_state.ToString(), m_state);
     if (m_control != null && m_control.InvokeRequired) {
         if (!m_control.Disposing && !m_control.IsDisposed && StateChanged != null) {
             m_control.Invoke(StateChanged,this, evargs);
         }
     } else {
         if (StateChanged != null)
             StateChanged(this, evargs); 
     }
 }
示例#8
0
 void lda_StateChanged(object sender, ILAlgorithmEventArgs e) {
     Info("Got state from " + ((ILAlgorithm) sender).Name + Environment.NewLine + 
          " " + e.Progress + " State: " + e.State); 
 }
示例#9
0
 void lda_ProgressChanged(object sender, ILAlgorithmEventArgs e) {
     Info("Got state from " + ((ILAlgorithm) sender).Name + Environment.NewLine + 
          " " + e.Progress + " State: " + e.State); 
     if (e.Progress > 0.5) {
         e.Cancel = true;
         Info("Cancelling excecution..."); 
     }
 }
示例#10
0
 /// <summary>
 /// helper function firing the progress changed event
 /// </summary>
 /// <param name="message">string to be send within the 
 /// <see cref="ILNumerics.Algorithms.ILAlgorithmEventArgs"/> </param>
 /// <returns>false if a handler of the event has attempted to cancel the 
 /// operation, true if the algorithm should continue normaly.</returns>
 protected virtual bool OnProgressChanged (string message) {
     ILAlgorithmEventArgs e = new ILAlgorithmEventArgs(m_progress, "Progress:" + message, m_state);
     if (ProgressChanged != null)
         ProgressChanged(this,e); 
     if (e.Cancel == true) 
         return false; 
     return true;
 }
示例#11
0
 /// <summary>
 /// helper function firing the state changed event
 /// </summary>
 /// <param name="message">string to be send within the 
 /// <see cref="ILNumerics.Algorithms.ILAlgorithmEventArgs"/> </param>
 /// <returns>false if a handler of the event has attempted to cancel the 
 /// operation, true if the algorithm should continue normaly.</returns>
 protected virtual bool OnStateChanged (string message) {
     ILAlgorithmEventArgs e = new ILAlgorithmEventArgs(m_progress, "State:" + message, m_state);
     if (StateChanged != null)
         StateChanged(this,e); 
     if (e.Cancel == true) {
         SetState(ILAlgorithmState.Canceled); 
         return false; 
     }
     return true; 
 }