|
-
May 23rd, 2004, 07:58 AM
#1
Thread Starter
Addicted Member
kill all app threads - RESOLVED
In vb6 i have this code to kill all my forms on exiting the app:
VB Code:
For Each frm In Forms
Unload frm
Set frm = Nothing
Next
It is possible to make something like this to kill my threads in VB.Net?
Thank you,
Guilherme Costa
Last edited by gccosta; May 23rd, 2004 at 08:49 AM.
-
May 23rd, 2004, 08:31 AM
#2
Frenzied Member
How about Application.Exit?
In vb.Net, forms are instances of a class. Thus, they have a scope. They can be declared in a module, form, event, etc, and exist within that scope. It's similar to dimming a variable. When the variable goes out of scope, it's gone.
That's kind of simplified, but is the basic idea. Form1 doesn't "load" (or unload) an existing Form2. It creates a new instance of Form2.
-
May 23rd, 2004, 08:48 AM
#3
Thread Starter
Addicted Member
I´ve done this sub to kill threads:
VB Code:
Public Sub finalizaThread(ByRef Tarefa As Thread)
Try
While Not Tarefa Is Nothing
If Tarefa.ThreadState = ThreadState.Suspended Or Tarefa.ThreadState = ThreadState.SuspendRequested Then
Tarefa.Resume()
Tarefa.Sleep(100)
Tarefa.Abort()
Else
Tarefa.Abort()
End If
Tarefa.Sleep(100)
Tarefa = Nothing
End While
Catch ex As Exception
gravaErro(ex)
End Try
End Sub
This sub solves my doubt!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|