private void AlgorithmFunctionTryWrapper(object parameter)
 {
     try {
         // ack the thread is running - signal to return async to callee
         m_waitforRunning = true;
         SetState(ILAlgorithmState.Running);
         object result = AlgorithmFunction(parameter);
         SetResult(result);
         if (m_cancelPending)
         {
             SetState(ILAlgorithmState.Canceled);
         }
         else
         {
             SetState(ILAlgorithmState.Finished);
         }
         m_cancelPending = false;
         m_thread        = null;
         OnAlgorithmFinished();
     } catch (ThreadAbortException) {
         m_state  = ILAlgorithmState.Canceled;
         m_thread = null;
         //throw new ILNumerics.Exceptions.ILException("The thread #" + m_thread.Name + "was interrupted.");
     }
 }
Example #2
0
 /// <summary>
 /// Construct a new ILAlgorithmEventArgs object for delivery
 /// </summary>
 /// <param name="progress">Current progress</param>
 /// <param name="message">A message to be included for the receiver of the event.</param>
 /// <param name="state">The state of the algorithm. Must be one out of the enum <typeparamref name="ILAlgorithmRunningState"/></param>
 public ILAlgorithmEventArgs (double progress,
                     string message, 
                     ILAlgorithmState state) {
     Progress = progress; 
     Message = message; 
     State = state;
     Cancel = false;
     Parameter = null; 
 }
 /// <summary>
 /// Construct a new ILAlgorithmEventArgs object for delivery
 /// </summary>
 /// <param name="progress">Current progress</param>
 /// <param name="message">A message to be included for the receiver of the event.</param>
 /// <param name="parameter">Additional user defined data to be transferred to event registrar</param>
 /// <param name="state">The state of the algorithm. Must be one out of the enum <typeparamref name="ILAlgorithmRunningState"/></param>
 public ILAlgorithmEventArgs(double progress,
                             string message,
                             ILAlgorithmState state,
                             object parameter)
 {
     Progress = progress;
     Message  = message;
     State    = state;
     Cancel   = false;
 }
Example #4
0
 /// <summary>
 /// set the current state for algorithm and provide message
 /// </summary>
 /// <param name="state">state enumeration value</param>
 /// <param name="message">additional message with reason of state change</param>
 /// <returns>false: if on of the registrars of the StateChanged event wishes to cancel the operation, true otherwise.</returns>
 /// <remarks><para>calling this method will fire a StateChanged event.</para>
 /// <para>the message will be delivered to registrars of the StateChanged event.</para></remarks>
 protected bool SetState(ILAlgorithmState state, string message)
 {
     m_state = state;
     return(OnStateChanged(message));
 }
Example #5
0
 /// <summary>
 /// set the current state for algorithm
 /// </summary>
 /// <param name="state">state enumeration value</param>
 /// <returns>false: if on of the registrars of the StateChanged event wishes to cancel the operation, true otherwise.</returns>
 /// <remarks><para>calling this method will fire a StateChanged event.</para>
 /// </remarks>
 protected bool SetState(ILAlgorithmState state)
 {
     return(SetState(state, ""));
 }
Example #6
0
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <remarks>Derived classes must call this base class constructor! This will set all
 /// private attributes to default (inital) values. </remarks>
 public ILAlgorithm()
 {
     m_state    = ILAlgorithmState.Initialized;
     m_progress = 0.0;
     m_name     = "ILAlgorithm derived class";
 }
Example #7
0
 private void AlgorithmFunctionTryWrapper(object parameter) {
     try {
         // ack the thread is running - signal to return async to callee
         m_waitforRunning = true; 
         SetState(ILAlgorithmState.Running); 
         object result = AlgorithmFunction(parameter); 
         SetResult(result); 
         if (m_cancelPending) 
             SetState(ILAlgorithmState.Canceled); 
         else 
             SetState(ILAlgorithmState.Finished); 
         m_cancelPending = false; 
         m_thread = null; 
         OnAlgorithmFinished(); 
     } catch (ThreadAbortException) {
         m_state = ILAlgorithmState.Canceled; 
         m_thread = null; 
         //throw new ILNumerics.Exceptions.ILException("The thread #" + m_thread.Name + "was interrupted."); 
     }
 }
Example #8
0
 private void SetState(ILAlgorithmState state) {
     m_state = state; 
     m_lastMessage = "State: '" + m_state.ToString() + "'"; 
     OnStateChanged(); 
 }
Example #9
0
 /// <summary>
 /// set the current state for algorithm and provide message
 /// </summary>
 /// <param name="state">state enumeration value</param>
 /// <param name="message">additional message with reason of state change</param>
 /// <returns>false: if on of the registrars of the StateChanged event wishes to cancel the operation, true otherwise.</returns>
 /// <remarks><para>calling this method will fire a StateChanged event.</para>
 /// <para>the message will be delivered to registrars of the StateChanged event.</para></remarks>
 protected bool SetState(ILAlgorithmState state, string message){
     m_state = state; 
     return OnStateChanged(message); 
 }
Example #10
0
 /// <summary>
 /// set the current state for algorithm
 /// </summary>
 /// <param name="state">state enumeration value</param>
 /// <returns>false: if on of the registrars of the StateChanged event wishes to cancel the operation, true otherwise.</returns>
 /// <remarks><para>calling this method will fire a StateChanged event.</para>
 /// </remarks>
 protected bool SetState(ILAlgorithmState state){
     return SetState(state,""); 
 }
Example #11
0
 /// <summary>
 /// Default constructor 
 /// </summary>
 /// <remarks>Derived classes must call this base class constructor! This will set all 
 /// private attributes to default (inital) values. </remarks>
 public ILAlgorithm() {
     m_state = ILAlgorithmState.Initialized; 
     m_progress = 0.0; 
     m_name = "ILAlgorithm derived class"; 
 }
 private void SetState(ILAlgorithmState state)
 {
     m_state       = state;
     m_lastMessage = "State: '" + m_state.ToString() + "'";
     OnStateChanged();
 }