how to dispose and object nicely.

Discussion in 'ASP .Net' started by =?Utf-8?B?QXNoYQ==?=, Mar 1, 2005.

  1. hello,

    i wants objects to be clean up after a page close, either by a button or by
    clickingon the x on the top right of the browser.
    so in vb.net i would use the finalize method... but how can this be done in
    c#? i want a finalize a methond. thanks
    =?Utf-8?B?QXNoYQ==?=, Mar 1, 2005
    #1
    1. Advertising

  2. Because of the way the web works, you will never know when a user closes the
    browser. The only time that the web server and the browser are connected are
    while the browser is fetching the page, they're disconnected once the page
    finished loading. After that, they don't talk until the user performs some
    action. Your best time to clean up the objects is right after you are
    finished with them. You don't have to necessarily clean up all the controls
    on a page, but, for example, you would need to make sure that a SqlReader
    that is bound to a DataGrid is closed after the DataGrid's DataBind() method
    is called and also that the SqlReader is then set to null to help the
    garbage collection pick it up. It doesn't matter if this is done in VB.Net
    or C#, they both have similar mechanics. The difference you're going to run
    into is moving from a Windows Forms environment to an ASP.Net Web Forms
    environment, and they often have very different behavior.

    Hope this helps,
    Mark Fitzpatrick
    Microsoft MVP - FrontPage

    "Asha" <> wrote in message
    news:...
    > hello,
    >
    > i wants objects to be clean up after a page close, either by a button or
    > by
    > clickingon the x on the top right of the browser.
    > so in vb.net i would use the finalize method... but how can this be done
    > in
    > c#? i want a finalize a methond. thanks
    Mark Fitzpatrick, Mar 1, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rob Meade

    Expire page, and display nicely

    Rob Meade, Jan 26, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    358
    Rob Meade
    Jan 26, 2004
  2. Antonio Concepcion
    Replies:
    3
    Views:
    2,721
    Antonio Concepcion
    Feb 17, 2005
  3. terry
    Replies:
    1
    Views:
    572
    VisionSet
    Jun 4, 2004
  4. fabrice
    Replies:
    4
    Views:
    2,312
    fabrice
    Nov 15, 2006
  5. allen.fowler

    How to set object parameters nicely?

    allen.fowler, Dec 1, 2009, in forum: Python
    Replies:
    11
    Views:
    382
    Bruno Desthuilliers
    Dec 3, 2009
Loading...

Share This Page