Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Finalizer problem

Finalizer problem

Scheduled Pinned Locked Moved C#
questioncsharpdotnetcomtools
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bob Stanneveld
    wrote on last edited by
    #1

    Hello, I have an application which has some global resources. I use some system resources in these classes. The finalizer is called when the application is closed. The problem is that a part of the .NET framework (System.Net.Sockets) gets disposed before my object is disposed. How do I make sure that my object is finalized before the system resources? Behind every great black man...             ... is the police. - Conspiracy brother Blog[^]

    M S 2 Replies Last reply
    0
    • B Bob Stanneveld

      Hello, I have an application which has some global resources. I use some system resources in these classes. The finalizer is called when the application is closed. The problem is that a part of the .NET framework (System.Net.Sockets) gets disposed before my object is disposed. How do I make sure that my object is finalized before the system resources? Behind every great black man...             ... is the police. - Conspiracy brother Blog[^]

      M Offline
      M Offline
      mav northwind
      wrote on last edited by
      #2

      Hi! I suggest you don't rely on a certain order of finalization (which is almost always a bad idea) but rather implement IDisposable and perform your cleanup in Dispose(). Regards, mav

      1 Reply Last reply
      0
      • B Bob Stanneveld

        Hello, I have an application which has some global resources. I use some system resources in these classes. The finalizer is called when the application is closed. The problem is that a part of the .NET framework (System.Net.Sockets) gets disposed before my object is disposed. How do I make sure that my object is finalized before the system resources? Behind every great black man...             ... is the police. - Conspiracy brother Blog[^]

        S Offline
        S Offline
        S Senthil Kumar
        wrote on last edited by
        #3

        Bob Stanneveld wrote:

        How do I make sure that my object is finalized before the system resources?

        That's not possible. In fact, members of an object might get finalized before the object itself. Regards Senthil _____________________________ My Blog | My Articles | WinMacro

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups