Solved

run animated gif on onclick

Posted on 2004-09-15
6
1,073 Views
Last Modified: 2012-05-05
my animated that shows work being done gif does not show when i click on the button.


CODE:

Ani.Visible = true; 'this is the animated gif

///Do Some Work that should take awhile to complete


Ani.Visible = false;

I've found that if I comment the 'Ani.Visible = false' out the gif would appear.

0
Comment
Question by:vinny45
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 24

Expert Comment

by:Justin_W
ID: 12071422
Is your "work" code running in a different thread?  If so, you need to wait for the thread to complete before making the GIF invisible again.
0
 
LVL 10

Accepted Solution

by:
eternal_21 earned 500 total points
ID: 12071599
CODE:

    System.Threading.Thread workThread = new System.Threading.Thread(new System.Threading.ThreadStart(DoSomeWork));
    workThread.IsBackground = true;
    workThread.Start();

You will need these methods too:

    void ShowAni()
    {
      Ani.Visible = true;
    }

    void HideAni()
    {
      Ani.Visible = false;
    }

    void DoSomeWork()
    {
      Invoke(new System.Threading.ThreadStart(ShowAni));
     
      // Do some work that should take a while to complete
     
      Invoke(new System.Threading.ThreadStart(HideAni));
    }
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 12080323
You might be able to use this:

Ani.Visible = true; 'this is the animated gif

Application.DoEvents;

Ani.Visible = false;

Bob
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 10

Expert Comment

by:eternal_21
ID: 12081514
TheLearnedOne, unfortunately that will work as far as displaying the image goes, but GIF animation will not occur.  The form's main thread is busy working, and does not animate the GIF.  The only solution is to move your work into another thread.
0
 

Expert Comment

by:malanois
ID: 12089520
eternal,

I have been working on another thread for the same thing.

how do you go about creating another thread for the gif.

http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/VB_DOT_NET/Q_21133658.html

Try:

showimage

Application.DoEvents <-- add this.

Fill
hideimage

Bob


 
Comment from malanois
Date: 09/16/2004 10:58AM PDT
 Your Comment  


hmmmmm????????

The gif comes up,

however the animation only shows on bar and hangs.???



 
Comment from TheLearnedOne  feedback
Date: 09/16/2004 10:59AM PDT
 Comment  


What happens if you don't do the Fill and don't hide the image?  Does the animation work correctly?

Bob
 
Comment from malanois
Date: 09/16/2004 11:05AM PDT
 Your Comment  


yes it works if i dont hide and unhide


 
Comment from TheLearnedOne  feedback
Date: 09/17/2004 07:01AM PDT
 Comment  


Take a look here:

http://www.experts-exchange.com/Programming/Programming_Languages/C_Sharp/Q_21132894.html#12081514

I learned something new, without even having to ask a question :)

Bob
 
Comment from malanois
Date: 09/17/2004 11:53AM PDT
 Your Comment  


that is great

Thank You so Much

:)

MJ
 
Comment from malanois
Date: 09/17/2004 12:43PM PDT
 Your Comment  


Well now you got me thinking,

Im trying to play with this.

Ive searched a couple items about thread and I keep getting errors

 Private thread As System.Threading.Thread

    Public Sub Threading()
        thread = New System.Threading.Thread(showimage)

    End Sub


    Public Sub showimage()
        showbx.Show()
    End Sub
    Public Sub hideimage()
        showbx.Hide()
    End Sub

?????????????????????

MJ
 
0
 
LVL 10

Expert Comment

by:eternal_21
ID: 12092312
malanois, I have converted the code to VB for your convienence:


  Public Sub ShowImage()

    pictureBox.Show()

  End Sub

  Public Sub HideImage()

    pictureBox.Hide()

  End Sub

  Private Sub DoWork()

    ShowImage()

    // Do your work here

    HideImage()

  End Sub

  Private Sub StartDoWork()

    Dim workThread As New System.Threading.Thread(AddressOf DoWork)
    workThread.Start()

  End Sub


Just call StartDoWork() to get the process going!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

631 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question