Solved

Form Disposal Question

Posted on 2003-11-14
5
189 Views
Last Modified: 2010-04-16
I have a question about how and when an instance of System.Windows.Form get's disposed.  Here is the scenario:

I created a form, showd it and then put a reference to said form in a hashtable.  I then closed the form.  When I later attempted to access the object through the hashtable I got an exception saying it had been disposed.  Shouldn't the reference in the hashtable be sufficient to keep this form from being disposed?  If not is there anyway to prevent the form from being disposed on closure?  Finally if I can't prevent the disposal on closure is there any way to determin if a reference refers to an object which has been previously disposed?
0
Comment
Question by:derekl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 10

Expert Comment

by:smegghead
ID: 9749220
What you can do is 'hide' the form rather than close it, this will prevent it from being disposed of.

Smg.
0
 

Author Comment

by:derekl
ID: 9749532
Which event do I need to override to provide this behavior?
0
 
LVL 10

Accepted Solution

by:
smegghead earned 125 total points
ID: 9749623
this.Hide();

rather than

this.Close();
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question