Results 1 to 3 of 3

Thread: Close vs. Dispose...??

  1. #1

    Thread Starter
    Lively Member spdracr's Avatar
    Join Date
    Oct 2003
    Location
    Kansas
    Posts
    115

    Question Close vs. Dispose...??

    Which would be better to be used?

    When I'm done with a form, should I just close it or dispose it?

    How 'bout a data connection??

    What are the advantages or disadvantages to using each??

    Thanks

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    The close method does the work of dispose in some cases, but you should dispose it just to be on the safe side.

    Same applies for ADO.NET.

    Advantages: Better app performance

    Disadvantages: I have no ****ing clue.

  3. #3
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by spdracr
    Which would be better to be used?
    When I'm done with a form, should I just close it or dispose it?
    How 'bout a data connection??
    What are the advantages or disadvantages to using each??
    Thanks
    Dispose method works a little different in the different objects .

    Forms :
    1-Use Close() method (will close the form if it's not the startup form of your project)
    Then
    2-Dispose() , to clean up the space taken , and reclaim memory .
    3-Set the form =Nothing . This de-reference any object that's connected to the form and mark it as out of scope for grabage collecting .


    As for ADO.NET :
    Same applies but more actions happen behind the scense like :
    When you use dispose the OleDbConnection object , you're removing it from the connection pool (whether on the server or locally) .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width