473,508 Members | 2,212 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Question on Threading

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
2 827
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
* "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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1485
by: David Harrison | last post by:
I am working on an application on Mac OS X that calls out to python via PyImport_ImportModule(). I find that if the imported module creates and starts a python thread, the thread seems to be...
5
2118
by: Richard P | last post by:
I need some help on timers. My app is asp.net 1.1 website running in a shared hosting environment with a third-party service provider. I currently request and cache 20 - 40 remote RSS feeds. When a...
11
4228
by: Mark Yudkin | last post by:
The documentation is unclear (at least to me) on the permissibility of accessing DB2 (8.1.5) concurrently on and from Windows 2000 / XP / 2003, with separate transactions scope, from separate...
13
7405
by: William Stacey | last post by:
Using the following code sample: public byte Get() { // <= Possible to switch Here?? lock(syncLock) { //Do something in Get(). } }
6
555
by: CK | last post by:
I have the following code in a windows service, when I start the windows service process1 and process2 work fine , but final process (3) doesnt get called. i stop and restart the windows service...
4
1196
by: Roger | last post by:
I have a function that is currently wrapped up in a Class so I can pass a variable to it. This function is going to be threaded out and I would like the class function to be able to update a...
6
1671
by: DarkBlue | last post by:
My application makes several connections to a remote database server via tcp/ip. Usually all is fine,but occasionally the server is down or the internet does not work and then there is the 30 sec...
4
321
by: DBC User | last post by:
I have a background process which reads a table to see if there are any pending requests. If there are any, then it will start a worker thread (only 10 allowed at a time) and executes a method. In...
4
1582
by: Steven | last post by:
I am taking an "advanced" VB.Net course via web at a state university toward an information science degree. This is my second VB class and I am kind of disappointed in it. This week we covered...
19
1787
by: frankiespark | last post by:
Hello all, I was perusing the internet for information on threading when I came across this group. Since there seems to be a lot of good ideas and useful info I thought I'd pose a question. ...
0
7227
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7391
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7054
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7501
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5633
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5056
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3204
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1564
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
424
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.