Stucked in Very Unusual Situation with WPF, Required urgent correction
===

I have stucked in very very unusual Problem , In my application , I am having one loop in which data is extracted from text files and on basis of that data chart is shown and then screenshot is taken. 

        **pseudo code**

        Loop Start
        data = extractdata();
      
         if some condition in data
            
            showchart();
            takescreenshot();

         end if
       Loop End

  When I run actual code based on above pseudo code , Not all charts are shown, screen remains blank, only last of them appear on screen. 

But when i add message box in code then every thing works perfectly as show in below   **pseudo code**

        Loop Start
         data = extractdata();
      
           if some condition in data
            
            showchart();
            MessageBox.Show("Hello") // Addition of this line solves all problem           
            takescreenshot();

           end if
       Loop End

     

Additional Information: Both these methods showchart() and takescreenshot() calls other functions in different classes 

 Inclusion of above line is just a temporary solution which indicates my background code is working fine and in my guess problem is something else like focus of wpf window or may be some thing else. This problem has spoiled my sleep of last two nights. I request you all senior members here to help me in solving this problem . I can not post source code because that is very lengthy and divided into many files.      