Dart.Emulation Namespace > TcpBase Class : StateChanged Event |
Public Event StateChanged As EventHandler
Dim instance As TcpBase Dim handler As EventHandler AddHandler instance.StateChanged, handler
public event EventHandler StateChanged
public: __event EventHandler* StateChanged
public: event EventHandler^ StateChanged
See the SynchronizingObject property for information on updating UI controls in your event handler.
This event can be raised during a Read call if the remote host closes the connection. In this scenario, a form should not be disposed of within this event handler if the Dart component was created on the form (this includes calling Form.Close if Form.Show was used to show it). Instead, the component can be created elsewhere and passed to the form, or the form can be disposed of after the posted Read returns.
private void myComponent_StateChanged(object sender, EventArgs e) { if (myComponent.State == ConnectionState.Closed) this.Text = "Not Connected"; else if (myComponent.State == ConnectionState.Connected) this.Text = "Connected to " + myComponent.RemoteEndPoint.ToString(); else this.Text = "Securely connected to " + myComponent.RemoteEndPoint.ToString(); }
Private Sub myComponent_StateChanged(ByVal sender As Object, ByVal e As EventArgs) If myComponent.State = ConnectionState.Closed Then Me.Text = "Not Connected" ElseIf myComponent.State = ConnectionState.Connected Then Me.Text = "Connected to " & myComponent.RemoteEndPoint.ToString() Else Me.Text = "Securely connected to " & myComponent.RemoteEndPoint.ToString() End If End Sub