Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 93371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:20:02+00:00 2026-05-10T23:20:02+00:00

Background In Visual Studio 2008 Create a new Windows Forms Application, this will create

  • 0

Background

In Visual Studio 2008 Create a new Windows Forms Application, this will create a skeleton project with a class called ‘Form1’. VS2008 automatically creates a Dispose() method.

    /// <summary>     /// Clean up any resources being used.     /// </summary>     /// <param name='disposing'>true if managed resources should be disposed; otherwise, false.</param>     protected override void Dispose(bool disposing)     {         if (disposing && (components != null))         {             components.Dispose();         }         base.Dispose(disposing);     } 

I wandered into a coworker’s office (a senior developer) – great guy, smart, good design skills for a chat – but I noticed what he was typing – as he navigated the codebase he deleted this section of the Dispose() methods that VS2008 created for the forms.

        if (disposing && (components != null))         {             components.Dispose();         } 

So, I asked him why and he said it wasn’t necessary to keep it in.

The Questions

  • Is it safe to delete this code?
  • What are the pros/cons of leaving it in or removing it?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T23:20:02+00:00Added an answer on May 10, 2026 at 11:20 pm

    Absolutely don’t delete it if there is the slightest chance of you ever using something like a System.Windows.Forms.Timer on the form. And there always is the chance of this.

    It’s this code which will dispose the timer when the form closes, and if you don’t dispose the timer then it will keep running. I have taken over several bits of code which have had this type of bug introduced (pre .NET 2.0 this mechanism didn’t work so well), and the resulting intermittent perf problems caused by timers running long after the forms they should update have closed can be a real pain.

    There is no realistic benefit to deleting this – if no controls have added themselves to the components list then components.Dispose() is going to be trivial to run. If controls have added themselves to the list then that’s because they ought to be disposed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 101k
  • Answers 101k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I think what you're trying to do is simply not… May 11, 2026 at 8:05 pm
  • Editorial Team
    Editorial Team added an answer "net.pipe" addresses a local transport. You need to use a… May 11, 2026 at 8:05 pm
  • Editorial Team
    Editorial Team added an answer As answered by bug-a-lot the Data Visualization classes and components… May 11, 2026 at 8:05 pm

Related Questions

I've created the default WCF Service in VS2008. It's called Service1 public class Service1
Background There are several different debug flags you can use with the Visual Studio
I have a C# (2008/.NET 3.5) class library assembly that supports WPF (based on
I am looking for the best way to test if a website is alive

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.