Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Finalize sub

Reply
Thread Tools

Finalize sub

 
 
=?Utf-8?B?U2FsYW1FbGlhcw==?=
Guest
Posts: n/a
 
      10-01-2006
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
 
Reply With Quote
 
 
 
 
Mark Rae
Guest
Posts: n/a
 
      10-01-2006
"SalamElias" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

>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...


 
Reply With Quote
 
 
 
 
=?Utf-8?B?U2FsYW1FbGlhcw==?=
Guest
Posts: n/a
 
      10-01-2006
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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
> >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...
>
>
>

 
Reply With Quote
 
Mark Rae
Guest
Posts: n/a
 
      10-01-2006
"SalamElias" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> 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...


 
Reply With Quote
 
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
Guest
Posts: n/a
 
      10-01-2006
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

 
Reply With Quote
 
Walter Wang [MSFT]
Guest
Posts: n/a
 
      10-02-2006
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 ((E-Mail Removed), 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.

 
Reply With Quote
 
=?Utf-8?B?U2FsYW1FbGlhcw==?=
Guest
Posts: n/a
 
      10-02-2006
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 ((E-Mail Removed), 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.
>
>

 
Reply With Quote
 
Walter Wang [MSFT]
Guest
Posts: n/a
 
      10-02-2006
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 ((E-Mail Removed), 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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Death To Sub-Sub-Sub-Directories! Lawrence D'Oliveiro Java 92 05-20-2011 06:50 AM
_id2ref in finalize or how get object.var from class.finalize Andrey Nikitin Ruby 1 12-16-2007 03:46 AM
_id2ref in finalize or how get object.var from class.finalize andrey Ruby 0 12-15-2007 04:55 PM
Recognising Sub-Items and sub-sub items using xslt Ben XML 2 09-19-2007 09:35 AM
throw exception in the finalize z. f. ASP .Net 1 07-05-2004 12:36 PM



Advertisments