Login  
Search All Forums
Dart Home | PowerTCP Emulation for .NET | Custom Development Reply | PowerTCP Emulation for .NET Topics | Forums   
AuthorForum: PowerTCP Emulation for .NET
Topic: Telnet Client hangs when closing form
zaphod

From: St-Eustache, QC Canada
Posts: 7
Member Since: 06/09/10
posted April 4, 2012 3:12 PM

Using the Telnet Client sample that came with Dart version 4.4.1, I wanted the application to close when the UNIX session is closed. In other words, when I log into a UNIX server, and then log out by typing exit at the prompt, the Telnet Client should also exit.

So I added the statement Me.Close() in the telnet1_StateChanged event and now the application hangs when I exit the UNIX session. Why ?

Here is the changed code:
Private Sub telnet1_StateChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles telnet1.StateChanged
 'Update interface to indicate connection
 vt1.Enabled = telnetModel.IsConnected

 If (vt1.Enabled) Then
  Me.Text = APP_NAME & (" [Connected to " & telnetModel.Telnet.RemoteEndPoint.ToString() & "]")
 Else
  Me.Text = APP_NAME & ("")
  Me.Close()
 End If

 connectToolStripMenuItem.Enabled = Not vt1.Enabled
End Sub
Nick B (Admin)

From: Utica, NY USA
Posts: 619
Member Since: 05/25/10

Extra Support Options
Custom Application Development

posted April 4, 2012 3:54 PM

Hello,

Thank you for your report; I've reproduced and logged this as TTWeb #5631. As a workaround, please use Application.Exit() instead of Me.Close().
Tony Priest



From: Utica, NY USA
Posts: 8466
Member Since: 04/11/00
posted April 5, 2012 8:39 AM

Zaphod, There was a problem with the forum last night that caused you to not be able to post your response. Please try to post your message again. We apologize for the inconvenience.
Nick B (Admin)

From: Utica, NY USA
Posts: 619
Member Since: 05/25/10

Extra Support Options
Custom Application Development

posted April 5, 2012 9:39 AM

Here is your response:

Thanks for the quick reply. Application.Exit() might work for the Telnet Client sample code, but It will not work for my application because my application is an MDI application, and I do not want to terminate the application when I exit a UNIX session, I just want to close the form.

I noticed that I was able to close the form outside of the StateChanged event without any problems, but that implies that the use must take another action before the form closes, and that is not the desired result. I want the form to close right after the telnet session closes.

Perhaps I could use another event that fires after the StateChanged event. Can you send me a list of all event s that fire when a telnet session closes.

Thanks.
Nick B (Admin)

From: Utica, NY USA
Posts: 619
Member Since: 05/25/10

Extra Support Options
Custom Application Development

posted April 5, 2012 10:49 AM

Hello,

You have two options then:

Use the Independent Data Source Telnet Client, so that you have access to the read loop; hook up the telnet UserState event, in that call this.Close(), and at the end of the ReceiveData() method in TelnetModel.cs call Telnet.Marshal("", null); (after the while loop exits).

Or, in the standard Telnet Client, change your StateChanged event to this:

private void telnet1_StateChanged(object sender, System.EventArgs e)
{
 //Update interface to indicate connection
 vt1.Enabled = telnetModel.IsConnected;

 this.Text = APP_NAME +
((vt1.Enabled) ? " [Connected to " + telnetModel.Telnet.RemoteEndPoint.ToString() + "]" : "");

 connectToolStripMenuItem.Enabled = !vt1.Enabled;

 if (!telnetModel.IsConnected)
 {
 Timer timer = new Timer();
 timer.Tick += new EventHandler(timer_Tick);
 timer.Interval = 1;
 timer.Start();
 }
}

void timer_Tick(object sender, EventArgs e)
{
 this.Close();
}
zaphod

From: St-Eustache, QC Canada
Posts: 7
Member Since: 06/09/10
posted April 5, 2012 2:52 PM

Thanks. I used the timer method and it worked fine.
Reply | PowerTCP Emulation for .NET Topics | Forums   
This site is powered by PowerTCP WebServer Tool PowerTCP WebServer for ActiveX