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

Home Posts Topics Members FAQ

Finalize sub

I started to use the Finalize sub in aspax page, I put a break point on one
of the lines, hit run with debug, the pages dispalys without breaking on the
line.

2nd question, do we need to use the keyword "set" as normal vb to set an
object to nothing or it is enough todo the following
"myobject = nothing"
instead of
"set myobject = nothing "
Thanks
Oct 1 '06 #1
7 1704
"SalamElias" <el******@online.nospamwrote in message
news:B4**********************************@microsof t.com...
>I started to use the Finalize sub in aspax page, I put a break point on one
of the lines, hit run with debug, the pages dispalys without breaking on
the
line.
What point are you making...?
2nd question, do we need to use the keyword "set" as normal vb to set an
object to nothing or it is enough todo the following
"myobject = nothing"
instead of
"set myobject = nothing "
"Normal VB"???

You need to stop thinking of VB.NET as the next version of VB6 - apart from
some obvious syntactic similarities, the two languages are pretty much
completely different...
Oct 1 '06 #2
For the first point, I don't how to be more clearthat that:
I am putting a breakpoint which I don't go through in debug operation?
I pass in Page_load, init and others except the Finalize

Hope this would be more clear

regarding VB, Iknow it is completly differnet, but I was wondering because I
am having strange /bizarre behavior in code setting obectstonothingin whenI
use the VBnet syntax
myobject =nothing

By normal VB Imeant VB6

Thanks

"Mark Rae" wrote:
"SalamElias" <el******@online.nospamwrote in message
news:B4**********************************@microsof t.com...
I started to use the Finalize sub in aspax page, I put a break point on one
of the lines, hit run with debug, the pages dispalys without breaking on
the
line.

What point are you making...?
2nd question, do we need to use the keyword "set" as normal vb to set an
object to nothing or it is enough todo the following
"myobject = nothing"
instead of
"set myobject = nothing "

"Normal VB"???

You need to stop thinking of VB.NET as the next version of VB6 - apart from
some obvious syntactic similarities, the two languages are pretty much
completely different...
Oct 1 '06 #3
"SalamElias" <el******@online.nospamwrote in message
news:E2**********************************@microsof t.com...
For the first point, I don't how to be more clearthat that:
I am putting a breakpoint which I don't go through in debug operation?
I pass in Page_load, init and others except the Finalize
Hmm - you have a Finalize in your aspx page's code-behind? Are you actually
*instantiating* this class, then...? Do you know what Finalize is...?
regarding VB, Iknow it is completly differnet, but I was wondering because
I
am having strange /bizarre behavior in code setting obectstonothingin
whenI
use the VBnet syntax
myobject =nothing
No - the behaviour you are getting is perfectly normal. On the other hand,
it might not be - it's difficult to tell, as you don't actually say what the
behaviour is that you consider to be strange / bizarre...
By normal VB Imeant VB6
Sigh...
Oct 1 '06 #4
You would almost never need to implement Finalize in an aspx page, the entire
page class is extinguished and goes out of scope as soon as the page has been
rendered. What makes you believe that just because you put a "Finalize Sub"
in your page class that something is going to call this method?

In actual fact, finalizers only need to be implemented when you hold onto
resources that need cleaning up.

Hope that helps.
Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"SalamElias" wrote:
I started to use the Finalize sub in aspax page, I put a break point on one
of the lines, hit run with debug, the pages dispalys without breaking on the
line.

2nd question, do we need to use the keyword "set" as normal vb to set an
object to nothing or it is enough todo the following
"myobject = nothing"
instead of
"set myobject = nothing "
Thanks
Oct 1 '06 #5
Hi SalamElias,

Welcome to VB.NET!

The Set and Let keywords are no longer needed/supported in VB.NET.

To understand why the Finalize method is not called during debug, you need
to first understand what is Garbage Collection by reading following
excellent article by Jeffrey Richter:

#Garbage Collection: Automatic Memory Management in the Microsoft .NET
Framework -- MSDN Magazine, November 2000
http://msdn.microsoft.com/msdnmag/issues/1100/gci/

For more information, please refer to following articles:

#Object.Finalize Method (System)
http://windowssdk.msdn.microsoft.com...ct.finalize.as
px

#Finalizers, Assembly Names, MethodInfo, and More
http://msdn.microsoft.com/msdnmag/is...05/NETMatters/

#Implementing Finalize and Dispose to Clean Up Unmanaged Resources
http://windowssdk.msdn.microsoft.com.../b1yfkh5e.aspx
Please feel free to let me know whether or not you need further
information. Thank you.
Sincerely,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 2 '06 #6
In fact I have objects declared on the page level, used by different Subs, so
I can not destroy them inside each sub, I need to have one place at the very
end of execution to destroy those objects.
This is the problem. Is there any alternative to use the finalize.
I will try to read the different articles and let you know

Thanks

"Walter Wang [MSFT]" wrote:
Hi SalamElias,

Welcome to VB.NET!

The Set and Let keywords are no longer needed/supported in VB.NET.

To understand why the Finalize method is not called during debug, you need
to first understand what is Garbage Collection by reading following
excellent article by Jeffrey Richter:

#Garbage Collection: Automatic Memory Management in the Microsoft .NET
Framework -- MSDN Magazine, November 2000
http://msdn.microsoft.com/msdnmag/issues/1100/gci/

For more information, please refer to following articles:

#Object.Finalize Method (System)
http://windowssdk.msdn.microsoft.com...ct.finalize.as
px

#Finalizers, Assembly Names, MethodInfo, and More
http://msdn.microsoft.com/msdnmag/is...05/NETMatters/

#Implementing Finalize and Dispose to Clean Up Unmanaged Resources
http://windowssdk.msdn.microsoft.com.../b1yfkh5e.aspx
Please feel free to let me know whether or not you need further
information. Thank you.
Sincerely,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 2 '06 #7
Hi,

Everytime a request is served by your page class, a instance of your page
class is recreated. Normally you don't have to explicitly destroy the
objects, even if they're declared on the page level. In fact, when
programming in .NET, you seldomly need to free/destroy your objects
explicitly. The Garbage Collector will free/destroy them at appropriate
time. If your object holds unmanaged resource, then you need to free them
in the Finalize method. However, when the Finalize method is called is
determined by the GC.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 2 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
21072
by: celeong | last post by:
Hi, anybody can help me with this. I've created a singleton class, and now wants to add destructor to it. I know we can implement the IDisposable and also overrides the Finalize method (from...
2
2054
by: Barry Anderberg | last post by:
I've been doing some reading about Finalize and garbage collection. I've learned that finalizing should be avoided because objects that have a finalize method require 2 (possibly more) itterations...
4
5060
by: Joe Abou Jaoude | last post by:
I m preparing to pass the 70-306 exam, so i downloaded Q & A from multiple sites. There's this question that really confuses me, coz i see that both answers A and C are both correct. Can anyone...
20
7472
by: Charles Law | last post by:
I have an application that creates a class. The class has unmanaged resources, so must end gracefully. How can I guarantee that the unmanaged resources are freed? I have looked at IDisposable,...
12
2091
by: Joe Abou Jaoude | last post by:
hi, I have a component that uses a database connection. In the finalizer I dispose the connection because I read in msdn the following: "A type must implement Finalize when it uses...
2
1280
by: eBob.com | last post by:
I have a user control which creates an Excel spread sheet and badly needs Dispose/Finalize. I've read up on the subject in Balena and I think I understand what is going on. But the VS generated...
4
2021
by: BLUE | last post by:
I've read many articles including the one from Duff's blog but I've many doubts. public static myClass Instance { get { if (myClass.instance == null) myClass.instance = new myClass();
5
1679
dmjpro
by: dmjpro | last post by:
i know that the finalize method is called by JVM when an object is garbage collected. right??? but the ultimate memory release done by native OS. now my confusion is ... when it is called in...
8
1861
by: Rob | last post by:
This is a weird one... I've got a class called PageInfo that has the following finalize code: Protected Overrides Sub Finalize() MyBase.Finalize() Do While m_TempFolders.Count Dim TempPath As...
0
7231
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
7133
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7405
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...
0
7504
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
5643
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
5059
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
3198
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1568
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
435
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.