473,395 Members | 1,343 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,395 software developers and data experts.

Who's referencing this form?

J
I'm wondering why the form created in the code below stays "alive". I would
have thought that because the form variable is local to the method, that
garbage collection would get rid of it. Makes me wonder if there is a
reference to it somewhere?

// a button on one form is used to call a static method on another form, the
static method creates the form
private void btnNewForm_Click(object sender, System.EventArgs e) {
FormDBSample.ShowForm();
}
//this is the static method that creates the form
public class FormDBSample : System.Windows.Forms.Form
{
....
public static void ShowForm( ){
Cursor.Current = Cursors.WaitCursor;
try{
FormDBSample frmSample = new FormDBSample();
frmSample.Show();
}
finally{
Cursor.Current = Cursors.Default;
}
}
Nov 15 '05 #1
2 1659
When you call Show method:
frmSample.Show();
the CLR creates a thread, and because of that frmSample
it's not collected.

Stefan
-----Original Message-----
I'm wondering why the form created in the code below stays "alive". I wouldhave thought that because the form variable is local to the method, thatgarbage collection would get rid of it. Makes me wonder if there is areference to it somewhere?

// a button on one form is used to call a static method on another form, thestatic method creates the form
private void btnNewForm_Click(object sender, System.EventArgs e) { FormDBSample.ShowForm();
}
//this is the static method that creates the form
public class FormDBSample : System.Windows.Forms.Form
{
....
public static void ShowForm( ){
Cursor.Current = Cursors.WaitCursor;
try{
FormDBSample frmSample = new FormDBSample();
frmSample.Show();
}
finally{
Cursor.Current = Cursors.Default;
}
}
.

Nov 15 '05 #2
When you call Show method:
frmSample.Show();
the CLR creates a thread, and because of that frmSample
it's not collected.

Stefan
-----Original Message-----
I'm wondering why the form created in the code below stays "alive". I wouldhave thought that because the form variable is local to the method, thatgarbage collection would get rid of it. Makes me wonder if there is areference to it somewhere?

// a button on one form is used to call a static method on another form, thestatic method creates the form
private void btnNewForm_Click(object sender, System.EventArgs e) { FormDBSample.ShowForm();
}
//this is the static method that creates the form
public class FormDBSample : System.Windows.Forms.Form
{
....
public static void ShowForm( ){
Cursor.Current = Cursors.WaitCursor;
try{
FormDBSample frmSample = new FormDBSample();
frmSample.Show();
}
finally{
Cursor.Current = Cursors.Default;
}
}
.

Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: jstaggs39 | last post by:
I want to create a Dcount and an If...Then...Else statement to count the number of records in a table based on the date that is entered to run the form. The If....Else statment comes in because if...
4
by: mplogue | last post by:
I have a form (frmMain) with a subform (frmSub), each with enumerated fields of the same name (txt1, txt2, etc). I'm trying to make a function that will take the values for each field in frmMain,...
0
by: J | last post by:
I'm wondering why the form created in the code below stays "alive". I would have thought that because the form variable is local to the method, that garbage collection would get rid of it. Makes...
17
by: Paul Helmuth | last post by:
All, (here's an easy one)... This is probably a stupid question - please bare with me as I am new to dotNet. How does one reference objects on a form from a module? In 6.0 you could simply...
2
by: Axel | last post by:
Hi, a question about something that seems very simple at first glance: is it possible to reference other controls of a subform in a query window without referencing through the parent form? I...
9
by: Alan | last post by:
Hmmm, I'm not too good with the syntax of referencing a subreport. I have frmInvoice which has the invoice details (e.g. ProductCode, ProductCost etc) in the subform frmInvoiceDetails. I'm trying...
21
by: cmd | last post by:
I have code in the OnExit event of a control on a subform. The code works properly in this instance. If, however, I put the same code in the OnExit event of a control on a Tab Control of a main...
2
by: JSBarten | last post by:
I have a class library that I'm using from both a windows form application and a web services. Is there a way to tell if the refrencing/executing assembly is a windows form application, web...
11
by: ozTinker | last post by:
I'm sure this shouldn't be too difficult, but I lack familiarity with the MS object model. Suppose I have a table "Purchase_Orders" and a form "TEMP" which I am using to look up a customer's...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.