/// <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); } } }
/// <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); }
/// <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); } } }
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; } }
/// <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); } }
/// <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); } }
void lda_StateChanged(object sender, ILAlgorithmEventArgs e) { Info("Got state from " + ((ILAlgorithm) sender).Name + Environment.NewLine + " " + e.Progress + " State: " + e.State); }
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..."); } }
/// <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; }
/// <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; }