Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: MCSD Certification Toolkit (Exam 70-483): Programming in C#
This is the forum to discuss the Wrox book MCSD Certification Toolkit (Exam 70-483): Programming in C# by Tiberiu Covaci, Rod Stephens, Vincent Varallo, Gerry O'Brien; ISBN: 978-1-118-61209-5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: MCSD Certification Toolkit (Exam 70-483): Programming in C# section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 31st, 2019, 01:02 PM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2019
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Managing Object Life Cycle

The Dispose method
Reply With Quote
  #2 (permalink)  
Old May 31st, 2019, 01:11 PM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2019
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 5

Question1:
The Dispose method
Reply With Quote
  #3 (permalink)  
Old May 31st, 2019, 07:09 PM
Rod Stephens's Avatar
Wrox Author
Points: 3,166, Level: 23
Points: 3,166, Level: 23 Points: 3,166, Level: 23 Points: 3,166, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

Quote:
The Dispose method’s main purpose is to clean up unmanaged resources, but it can also clean up managed resources.

If the class has only managed resources, it should implement IDisposable but it doesn’t need a destructor.

Question is why we "should" implement IDisposable. Garbage collector cleans up managed resources. Maybe for immediate cleanup?
Exactly. The garbage collector will eventually get around to cleaning up managed resources, but you don't know long that may take.

For an example, suppose an object opens and locks a file, and then the program stops using that object. The file may remain open and locked. Eventually the garbage collector will destroy the file stream, but other programs may want to use the file in the meantime. For instance, you might want to use File Explorer to delete it. In fact, other parts of the same program might want to use or delete the file.
__________________
Rod

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)

Last edited by Rod Stephens; June 3rd, 2019 at 10:52 AM..
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 3 page 52-53 Activity Life cycle herbchess BOOK: Beginning Android Programming with Android Studio, Fourth Edition 0 January 16th, 2018 02:58 PM
Null or Cycle Entertainment Unit BOOK Programming Interviews Exposed: Secrets to Landing Your Next Job 3rd Edition 1 December 22nd, 2014 05:59 PM
Here is Practical Explanation about Next Life, Purpose of Human Life - alex.o RSS and Atom 0 November 22nd, 2014 01:33 PM
Tomcat life cycle listener dp_java Apache Tomcat 0 August 21st, 2006 06:39 AM
Simplify your life with Object Binding sarosh .NET Framework 2.0 0 March 31st, 2006 01:38 AM



All times are GMT -4. The time now is 03:28 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.