public void Start( Utility.Threading.Action action ) { if( action == null ) { throw new ArgumentNullException( "action" ); } if( _animationControl.Animation == null ) { throw new InvalidOperationException( "No animation set." ); } lock( _lock ) { if( _action != null ) { throw new InvalidOperationException( "Already processing." ); } _action = action; OnProcessingBegin( EventArgs.Empty ); ThreadStart ts = new ThreadStart( ThreadFunc ); Thread thread = new Thread( ts ); thread.Start(); } }
private void ThreadFunc() { try { _action( _progress ); lock( _lock ) { _action = null; } if( IsHandleCreated && !_progress.IsCancelled ) { Invoke( new EndSuccessDelegate( EndSuccessCrossThread ) ); } } catch( Exception e ) { lock( _lock ) { _action = null; } if( IsHandleCreated && !_progress.IsCancelled ) { Invoke( new EndFailureDelegate( EndFailureCrossThread ), e ); } } }
public void Start( Utility.Threading.Action action, Control invoker ) { if( action == null ) { throw new ArgumentNullException( "action" ); } if( invoker == null ) { throw new ArgumentNullException( "invoker" ); } lock( _lock ) { if( _action != null ) { throw new InvalidOperationException( "Already processing." ); } _action = action; _invoker = invoker; _progress = new Utility.Threading.Progress(); OnProcessingBegin( EventArgs.Empty ); ThreadStart ts = new ThreadStart( ThreadFunc ); Thread thread = new Thread( ts ); thread.Start(); } }