[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Animated Icon

Posted on 2010-09-14
3
Medium Priority
?
401 Views
Last Modified: 2012-05-10
I have a form that when a button is clicked it triggers another form to popup and reads "Waiting" with an animated spinning arrows gif  
The problem is that when the waiting form is displayed the gif is moving then stops and then moves random.  I think the process, LocalDataCache1SyncAgent() which sync's local sql db to server sql 2005 on the parent form seems to be the problem, but am not sure.  I have tried progress bar and it does the same thing, just does not seem to have movement after the process starts on the parent.  I have even tried starting the process off on the parent form with ..Application.DoEvents() and still does not work..

Any ideas to get a continus smooth running gif while the parent process runs would be greatly appreciated.
0
Comment
Question by:H-SC
[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
  • 2
3 Comments
 
LVL 7

Expert Comment

by:klakkas
ID: 33672383
The problem is that both forms run in the same thread, so the animation of the first form is blocked by the processing done by the second form.

The solution is to use a backgroundWorker, either in the parent form to call the second one:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Button1.Image =anim 'Animation gif
        BackgroundWorker1.RunWorkerAsync()
    End Sub

    Private Sub BackgroundWorker1_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
        Dim f2 As New Form2
        f2.Show()
    End Sub


Or (more efficient in my opinion) use the backgroundWorker in the second form:

Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
       BackgroundWorker1.RunWorkerAsync()
    End Sub

Private Sub BackgroundWorker1_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
     'Do the necessary processing
    End Sub

    End Sub
0
 
LVL 7

Accepted Solution

by:
klakkas earned 2000 total points
ID: 33672443
In general, the best practice is to put all your heavy work in a backgroundWorker, in order to allow the user interface to work without problems.

So, after reading again your description, the best practice ( in my opinion) is the following:

Dim fWait as frmWait
Private Sub btnDoHeavyWork_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDoHeavyWork.Click
     fWait = new frmWait
     f.show
     BackgroundWorker1.RunWorkerAsync()
end sub

Private Sub BackgroundWorker1_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
     'Do the necessary processing
    End Sub

    Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
     fWait.close()
    End Sub
0
 
LVL 1

Author Comment

by:H-SC
ID: 33673250
klakkas,

Many thanks!  Simply brilliant, not sure why I did not think of the background worker...  It is working smooth!

thanks again
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

649 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