0
Hey Alan,
True... I'm passing a ref. This is how it goes:
class Connection : System.Socket
{
Socket m_Connection;
/* object init stuff */
public void Connect(....)
{
m_Connection.Connect(.....);
}
} //end of class
class ChildForm : System.Windows.Forms.Form
{
Connect m_NewConnection;
/* object init stuff */
//OK Button which establishes a connection
private void but_OK (object sender, System.EventArgs e)
{
m_NewConnection.Connect(....);
this.Hide(); //hiding the form.. for temporarily?
}
} //end of class
class ParentForm : System.Windows.Forms.Form
{
ChildForm m_NewChildForm;
Connection m_NewConnection; //****KEY REF. OBJ ******//
/* object init stuff */
private void Form_Load (....)
{
m_NewConnection = mNewChildForm.m_NewConnection; //Getting the reference
m_NewChildForm.Show(); //how do i exit this form and keep the connection?
}
}
So as you can probablly figure out that in the Parent form that I'm executing the child Show() method, establish the "connection" and then hiding the child form.
So, my original question was, do I've to keep the form on hiding till I've connection on? Users here described that hiding the form is a waste of memory (obviously) so what else can I do? Deactivate it? Or Disable it?
Thanks very much Alan.
JJ

0
That's wierd....It shouldn't be terminating your connect if you are passing the object back to the parent. I assume you are passing the reference to it back and not the object itself?
0
Hi Alan,
Thanks for replying first of all. By "new form" you mean the parent form? I was already doing what you suggested it over here. My childForm is the one which initializes the Socket.Connect(...) method, and I'm returning the reference to my parent form. Then I issue the childForm.Close(). Yet, it still terminates the connection link.
So, that's why I'm hiding the child form until the whole TCP connection exists. Say for example, till the transfer of a 50 meg file.
Cheers,
JJ
0
What you should do, in that case, is to pass the TCPConnection object onto the new form that is displayed, then you can safely issue the childForm1.Close() command. You may have to create a public or internal method in the childForm that simply returns the TCPConnection. They your new form can call the method, get the TCP connection, then you can Close() the childForm
Alan
0
Hey Zelda,
The thing is, my child form has to be alive because it initiates a TCP connection and establishes a link with a FTP server. So, when I issue the childForm1.Close(), the connection terminates.
So, I've to hide the childform through the lifetime of the connection. Is this normal?
Your idea reinforced my thoughts. Thanks buddy.
Jey
0
JJ,
I wrote a similiar program not to long ago and that's sort of how I handle it. Of course, it really depends on how you're using these MDI child forms. If you don't plan on using the child form again, you use form1.Close(). Otherwise, you would hide it until it's next use.
However, sometimes you may want to close these forms to free up memory. In this case, you would have to do a form1 = new Form(), and then do other initializing before calling form1.Show().
I hope this helps.