473,396 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Form.ShowDialog

33
Hi:
I search through this forums and google around about this Form.ShowDialog():
I'm unable to make the event at Child Form stop running and It looks like the child Form is still "Alive":

Here:
At Form1
Expand|Select|Wrap|Line Numbers
  1.         private void button1_Click(object sender, EventArgs e)
  2.         {
  3.  
  4.             Form2 frm2 =new form2();
  5.             frm2.ShowDialog();
  6.  
  7.  
At Form 2

Expand|Select|Wrap|Line Numbers
  1.   private void button1_Click(object sender, EventArgs e)
  2.         {
  3.             this.Dispose();
  4.  
  5.         }
  6.  
Very Simple? But when I check the Output Window, Form2 is still performing Console.Writeline

Thanks
Apr 25 '09 #1
2 3438
tlhintoq
3,525 Expert 2GB
try
this.close();

instead of
this.dispose();

Generally speaking, you don't call .dispose(). It gets called automatically when the object goes out of scope and the resources are to be recovered for the application. You can't dispose of it if it is still in existence. It still exists until you close it, and all references to it go out of scope.
Apr 25 '09 #2
Jetean
33
@tlhintoq
It is still the same. I tried both before I posted this. Have you tried At Form2:
create new timer (System.Timer) and performed counting and output with Console.Writeline, then close Form2 (Open Form2 from Form 1 either with Form2.ShowDialog or Show()), the Timer event is still working even Form2 is disposed! (I thought object after disposed should be collected by GC and vanishded since it already out of scope?)

Now if replace System.Timer with Timer (from toolbox) , ha ha, there is a difference! The Console.Writeline stop running (well is Form2 actually disposed???)

What If I have event that will fired and Form2 subscribe from the Form1 Event?
(I tested it, Form 2 with console writeline at the method that subscribed to Form1 is still running even Form2 is Closed or Disposed !!!)

Is this what described as :"Memory Leaked"?


How can make sure Form2 is really disposed and no more working "in the background" ....

PS: VB6 have a method call unloading.

Thanks
Apr 26 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: C M Shaw | last post by:
I have a form which I want to show modally; it's a fairly old form that's been ported up several versions of VB, and I'd like to keep its rewriting to a minimum. Basically, it is used in this...
5
by: Engineerik | last post by:
I have a login form which I want to display with the showdialog method. When I do that the event handler for the load event does not run. If I use the show method the load event handler runs...
10
by: Partha Protim Roy | last post by:
Hello, My problem is: I got a Login form, so once the user enter vaild Username & Password another form opens. How do I close the login form?
4
by: trialproduct2004 | last post by:
Hi all I am new to vb.net application. I am using showdialog property of form to display form. First time it is working properly. But next time it is giving me error that ' object reference not...
7
by: Boni | last post by:
Dear all, if I do myform.close() is it disposed or not? is it correct do following? myForm.close() Info=SomeControlOntheForm.text This seems to work. But am not sure that it is waterproof....
2
by: **Developer** | last post by:
I have a little more info about this problem I can't seem to solve! I know it'll take a minute to study the lising but if you like to sove puzzles there is one there. I have a Form (FV&C)...
5
by: Miro | last post by:
I will try my best to ask this question correctly. I think in the end the code will make more sence of what I am trying to accomplish. I am just not sure of what to search for on the net. I...
4
by: active | last post by:
At the statement: FormEdit.ShowDialog() I get the following: Form that is not a top-level form cannot be displayed as a modal dialog box. Remove the form from any parent form before...
1
by: Frank Rizzo | last post by:
I am not grokking the difference between Form.ShowDialog() and Form.ShowDialog(this). I have a form (parent form) that kicks off a modal dialog using Form.ShowDialog(). The modal dialog has a 3rd...
3
by: bsturg21 | last post by:
Hello, I have a windows form that has a series of linklabels on it, and I need to have each linklabel, when clicked, open a separate windows form that has a single paramter passed into it. The...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.