[Quantproject-developers] QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardOneRank ProgressBarF
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2005-04-24 16:23:59
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardOneRank In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24156/b7_Scripts/WalkForwardTesting/WalkForwardOneRank Modified Files: ProgressBarForm.cs Log Message: - rewritten to work with any IWalkForwardProgressNotifier - rewritten to work in its own thread (different from the main thread) Index: ProgressBarForm.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardOneRank/ProgressBarForm.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ProgressBarForm.cs 29 Nov 2004 14:34:26 -0000 1.1 --- ProgressBarForm.cs 24 Apr 2005 16:23:50 -0000 1.2 *************** *** 5,8 **** --- 5,10 ---- using System.Windows.Forms; + using QuantProject.ADT; + namespace QuantProject.Scripts.WalkForwardTesting.WalkForwardOneRank { *************** *** 33,37 **** } ! public ProgressBarForm() { // --- 35,39 ---- } ! public ProgressBarForm( IWalkForwardProgressNotifier walkForwardProgressNotifier ) { // *************** *** 45,50 **** --- 47,86 ---- this.progressBarOutOfSample.Maximum = 100; this.progressBarInSample.Maximum = 100; + walkForwardProgressNotifier.InSampleNewProgress += + new NewProgressEventHandler( this.inSampleNewProgressEventHandler ); + walkForwardProgressNotifier.OutOfSampleNewProgress += + new NewProgressEventHandler( this.outOfSampleNewProgressEventHandler ); } + private void inSampleNewProgressEventHandler( + object sender , NewProgressEventArgs newProgressEventArgs ) + { + if ( this.InvokeRequired ) + { + // we're not in the UI thread, so we need to call BeginInvoke + this.BeginInvoke( new NewProgressEventHandler( this.inSampleNewProgressEventHandler ) , + new object[]{ sender , newProgressEventArgs }); + } + else + // we are in the UI thread + { + this.progressBarInSample.Value = newProgressEventArgs.CurrentProgress; + } + } + private void outOfSampleNewProgressEventHandler( + object sender , NewProgressEventArgs newProgressEventArgs ) + { + if ( this.InvokeRequired ) + { + // we're not in the UI thread, so we need to call BeginInvoke + this.BeginInvoke( new NewProgressEventHandler( this.outOfSampleNewProgressEventHandler ) , + new object[]{ sender , newProgressEventArgs }); + } + else + // we are in the UI thread + { + this.progressBarOutOfSample.Value = newProgressEventArgs.CurrentProgress; + } + } /// <summary> /// Clean up any resources being used. |