S
Sid Price
I have been reading about the managed heap and garbage collection and I have
a question. I have a class that has a very simple task and that is to send a
UDP message to a remote computer. The caller simply creates an instance of
the class with appropriate parameters and the class takes care of the
sending. The caller creates this instance and it goes out of scope almost
right away. In the "New" sub of the class a thread is created and started to
send the command data, this thread exits once it is done. So, the question
is, will the GC detect that the object is no longer in use when the thread
exits and dispose of it or is it "disposable" as soon as the object goes out
of scope?
The class "Trigger" is like this:
Public Class Trigger
Public Sub New(byval strAddress as string, byval strCommand as string)
mThread = new Thread(addressof SendCommand)
mThread.Start()
End Sub
Private Sub SendCommand()
... Do work here
End Sub
... other class methods etc
End Class
And the is like:
Public Sub VM_Send(byval strAddress as string, byval strData as string)
Dim oCommand as new Trigger(strAddress,strData)
End Sub
Thanks,
Sid.
a question. I have a class that has a very simple task and that is to send a
UDP message to a remote computer. The caller simply creates an instance of
the class with appropriate parameters and the class takes care of the
sending. The caller creates this instance and it goes out of scope almost
right away. In the "New" sub of the class a thread is created and started to
send the command data, this thread exits once it is done. So, the question
is, will the GC detect that the object is no longer in use when the thread
exits and dispose of it or is it "disposable" as soon as the object goes out
of scope?
The class "Trigger" is like this:
Public Class Trigger
Public Sub New(byval strAddress as string, byval strCommand as string)
mThread = new Thread(addressof SendCommand)
mThread.Start()
End Sub
Private Sub SendCommand()
... Do work here
End Sub
... other class methods etc
End Class
And the is like:
Public Sub VM_Send(byval strAddress as string, byval strData as string)
Dim oCommand as new Trigger(strAddress,strData)
End Sub
Thanks,
Sid.