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
Printable View
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
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.
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!!