HomeChallengesRepsProblemsLeaderboardTake a challenge

Giving the handle back

A file handle held for the life of the process. Implement the pattern properly.

Beginner15 min on the clock5 graded checks · 100 pointsResources and Concurrency
Graded by reading your code against the checklist below.

What you build

  • Implement IDisposable so callers can use `using`
  • Put the work in a protected virtual Dispose(bool), not in the public method
  • Tell the GC it no longer needs to finalise this object
  • Make a second Dispose() call harmless
  • Actually dispose the fields you own

Done means

IDisposable implemented with the full pattern, idempotent, suppressing finalisation.

How it is graded

Published in full, before you start — every point is one of these and there is nothing else.

  1. It implements IDisposable+25Giving resources back
  2. The work is in a protected virtual Dispose(bool)+25Giving resources back
  3. It suppresses finalisation+20Giving resources back
  4. Disposing twice is harmless+15Giving resources back
  5. The fields it owns are actually disposed+15Giving resources back

What it teaches

The rest of Resources and Concurrency