@@ -640,15 +640,7 @@ private void expositionBW_DoWork(object sender, DoWorkEventArgs e)
640
640
// Sending mark to neuronspectrum to sinalize that exposition of stimulus started
641
641
SendKeys . SendWait ( executingTest . Mark . ToString ( ) ) ;
642
642
executingTest . ExpositionTime = DateTime . Now ;
643
- try
644
- {
645
- showStimulus ( ) ;
646
- }
647
- catch ( Exception )
648
- {
649
-
650
- }
651
-
643
+ showStimulus ( ) ;
652
644
653
645
if ( intervalCancelled )
654
646
{
@@ -674,7 +666,21 @@ private void expositionBW_DoWork(object sender, DoWorkEventArgs e)
674
666
/* just wait for exposition time to be finished */
675
667
}
676
668
}
677
- between = true ;
669
+ // if current control is enabled it means that just showed a stimulus
670
+ if ( currentControl . Enabled )
671
+ {
672
+ // signaling to interval background worker that exposing must end and control must be removed from screen
673
+ exposing = false ;
674
+ intervalBW . ReportProgress ( 50 , currentControl ) ;
675
+ }
676
+ if ( e . Cancel )
677
+ {
678
+ between = false ;
679
+ }
680
+ else
681
+ {
682
+ between = true ;
683
+ }
678
684
if ( Player . SoundLocation != null )
679
685
{
680
686
Player . Stop ( ) ;
@@ -689,7 +695,7 @@ private void expositionBW_DoWork(object sender, DoWorkEventArgs e)
689
695
betweenAttemptsStopWatch = new Stopwatch ( ) ;
690
696
betweenAttemptsStopWatch . Start ( ) ;
691
697
692
- while ( betweenAttemptsStopWatch . ElapsedMilliseconds < executingTest . ProgramInUse . IntervalBetweenAttempts )
698
+ while ( betweenAttemptsStopWatch . ElapsedMilliseconds < executingTest . ProgramInUse . IntervalBetweenAttempts && ! ( e . Cancel ) )
693
699
{
694
700
if ( expositionBW . CancellationPending )
695
701
{
@@ -720,6 +726,7 @@ private void expositionBW_ProgressChanged(object sender, ProgressChangedEventArg
720
726
721
727
private void expositionBW_RunWorkerCompleted ( object sender , RunWorkerCompletedEventArgs e )
722
728
{
729
+ Console . WriteLine ( cancelExposition ) ;
723
730
if ( ! cancelExposition )
724
731
{
725
732
// cleaning screen
@@ -753,7 +760,7 @@ private void expositionBW_RunWorkerCompleted(object sender, RunWorkerCompletedEv
753
760
currentExposition + 1 , expositionAccumulative , currentLists , currentStimuli , currentPositionOutput , currentBeep , currentColor ,
754
761
ReactionProgram . responseTimeType [ ReactionProgram . AFTER_EXPOSITION ] ) ;
755
762
}
756
- if ( ( e . Cancelled == true ) && ! intervalCancelled )
763
+ else if ( ( e . Cancelled == true ) && ! intervalCancelled )
757
764
{
758
765
/* user clicked after stimulus is shown*/
759
766
executingTest . writeLineOutput ( intervalElapsedTime , intervalShouldBe , hitStopWatch . ElapsedMilliseconds ,
@@ -796,6 +803,7 @@ private void intervalBW_DoWork(object sender, DoWorkEventArgs e)
796
803
Thread . Sleep ( 1 ) ;
797
804
798
805
}
806
+ Thread . Sleep ( 50 ) ;
799
807
}
800
808
801
809
private void intervalBW_RunWorkerCompleted ( object sender , RunWorkerCompletedEventArgs e )
0 commit comments