Open Form New Thread And Then Stopping Thread (Close Form)

Posted on 2012-08-13
Last Modified: 2012-08-17
So here's the deal. I have a form that does rather a lengthy process. While this is running I want to open another form that has an animated gif that runs to show that the application is 'thinking'.  If I just open the form while the other process is running the animated gif becomes just a black box. However, if I do this:

 Private Sub openUpdate()
 End Sub

And call that using this:

 Dim t As Thread
 t = New Thread(AddressOf Me.openUpdate)

Everything works as I want it to. But, how do I then close that thread? I have looked at a few things here on EE and using google, but I can't really find a solution. Many things about threadname.abort, but I can't get that to work.  There is a function that runs on my main form that when it finishes I want to close this thread. So I will be stopping the thread from the main form.

Any ideas? I hope this makes sense. Also, if there is a better way of doing this I am all ears (or eyes in this case).

Thanks for any ideas.
Question by:G Scott
    LVL 83

    Expert Comment

    How about doing the processing in separate thread and showing the form on main UI thread?
    LVL 1

    Author Comment

    by:G Scott
    Hey CodeCruiser, I am open to that, I just have no idea how to go about doing that.
    LVL 85

    Accepted Solution

    Put that "lengthy process" into another thread using a BackgroundWorker() control hosted in your Form with the animated GIF:
    LVL 27

    Expert Comment

    Project->Properties->Application->Shutdown mode = When startup form closes and forget about thread's count
    LVL 1

    Author Closing Comment

    by:G Scott
    I worked it out using BackgroundWorker. Thanks!

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Article by: jpaulino
    XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String ( Literal, only instead of starting and ending with w…
    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    728 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now