• 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()
        System.Windows.Forms.Application.Run(updatingSlides)
 End Sub

And call that using this:

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

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

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