Results 1 to 3 of 3

Thread: Animated GIF - Seperate Thread? DoEvents?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2006
    Posts
    65

    Red face Animated GIF - Seperate Thread? DoEvents?

    Hey PPL!

    Still creating my first serious .Net App and I think a thread will be the answer to this question but I dont how to apply it...

    I am creating an application that generates large Crystal Reports. The datasets for these reports take a considerable amount of time to create. During this time I show a small TopMost form with a simple wait message.

    Recently I added an animated gif using a System.Windows.Forms.PictureBox control. I have done this to show the PC is still active and hasn't halted.

    The problem is the processor is too busy making a dataset to animate the gif. All I get is 2 or 3 frames. I would suspect that placing the animation in its own thread would solve this problem. We could have nice animations and dataset generation all at once. BUT HOW?? Right now it looks like this:
    VB Code:
    1. Dim frm as New frmWait
    2. ....
    3.  
    4. frm.Show()
    5. Application.DoEvents                         'Ensure paint has finished
    6. ...
    7. GenerateRptData()
    8. ....
    9. frm.Close()
    Obviously without the call to generate the data the animation is displayed perfectly. With the data call we get a staggered, dodgy looking result.

    I simply dont have enough threading experience to solve this problem. If I place a DoEvents in the data generation code it helps but still not as good as it could be. I need to somehow place the picturebox drawing code into its own thread. I think...

    Any ideas guys, is multthreading the answer or am I way off.

    Using: VS2003 & .Net 1.1

    Thanks for your help in advance,
    Matt.

  2. #2
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: Animated GIF - Seperate Thread? DoEvents?

    It would probably need to be done with threading. You should do the crystal report generation in a seperate thread, freeing up the form's GUI thread so it can refresh like its supposed to. In 2005, this can easily be done using a BackgroundWorker, but in 2003, you have to do it manually by creating a seperate thread. Below are some links I have bookmarked that is some good reading on threading...

    Give Your .NET-based Application a Fast and Responsive UI with Multiple Threads
    http://msdn.microsoft.com/msdnmag/is...g/default.aspx

    Asynchronous Programming Design Patterns
    http://msdn2.microsoft.com/en-us/lib...69(VS.80).aspx

    Managed Threading
    http://msdn2.microsoft.com/en-us/lib...dd(VS.80).aspx

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2006
    Posts
    65

    Re: Animated GIF - Seperate Thread? DoEvents?

    You should do the crystal report generation in a seperate thread, freeing up the form's GUI thread so it can refresh like its supposed to.
    Great answer and thanks for the links!

    But alas I too had thought of this. The data generation takes about 50% of the total time time needed to display the report, the rest of the time is spent instantiating the report object, assigning the built dataset to the Crystal Report viewer and finally showing the report form.

    All these other tasks take time and interact with various project variables. I assume this functionality could all be handled via the correct use of threading, waits and blocking but this is knowledge i dont have.

    I may just have to live with it until my threading knowledge is up to scratch but thanks for your help gigemboy.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width