By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,524 Members | 1,475 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,524 IT Pros & Developers. It's quick & easy.

Question on Threading

P: n/a
I have the something like the following code to start a new thread :

Sub StartThread()
Dim oProcessingObject As New MyObj.MyClass
Dim oThread As Thread
Dim oSomeObject as New SomeObject.SomeClass
oSomeObject.Property = "A value"

oThread = New Thread(AddressOf MyObj.MyClass)
oProcessingObject.oPropertySomeObject = oSomeObject
oThread.Start()

End Sub

Do I need to worry about how oSomeObject is destroyed ? Will the garbabge
collector simply clear it up when the thread has finished ?

Thanks

Steve

Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Steve,

When it is not special said you never should have to concern about how an
object is destroyed. Therefore it is managed code.

The link bellow is a large text. Where you probably can read it, what is not
in this text is that any class (by instance your form) that implements
Idisposable and where components are created in the right way there these
components (including the so called unmanaged resources) are destroyed
afterwards.

However it is advice by instance to dispose large objects as bitmaps by code
as well as a database connection where as far as I knowthey have coded
something extra in the dispose for the connectionpooling, and there are some
more.

http://msdn.microsoft.com/architectu...l/scalenet.asp

I hope this helps?

Cor
Nov 21 '05 #2

P: n/a
* "Steve W" <Bu******@community.nospam> scripsit:
I have the something like the following code to start a new thread :

Sub StartThread()
Dim oProcessingObject As New MyObj.MyClass
Dim oThread As Thread
Dim oSomeObject as New SomeObject.SomeClass
oSomeObject.Property = "A value"

oThread = New Thread(AddressOf MyObj.MyClass)
oProcessingObject.oPropertySomeObject = oSomeObject
oThread.Start()

End Sub

Do I need to worry about how oSomeObject is destroyed ? Will the garbabge
collector simply clear it up when the thread has finished ?


If 'oSomeObject' is "destroyed" doesn't have anything to with the thread
you start. If there are no references to the object when the end of
'StartThread' is reachted, the GC will be allowed to destroy the object
in a cleanup pass.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.