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
Printable View
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
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. :)
Dispose method works a little different in the different objects .Quote:
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
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) .
:afrog: