• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 301
  • Last Modified:

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

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.
G Scott
G Scott
1 Solution
How about doing the processing in separate thread and showing the form on main UI thread?
G ScottAuthor Commented:
Hey CodeCruiser, I am open to that, I just have no idea how to go about doing that.
Mike TomlinsonMiddle School Assistant TeacherCommented:
Put that "lengthy process" into another thread using a BackgroundWorker() control hosted in your Form with the animated GIF:
Project->Properties->Application->Shutdown mode = When startup form closes and forget about thread's count
G ScottAuthor Commented:
I worked it out using BackgroundWorker. Thanks!

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now