Dart.Sockets Namespace > Tcp Class : Start Method |
'Declaration Public Sub Start( _ ByVal worker As WaitCallback, _ ByVal state As Object _ )
'Usage Dim instance As Tcp Dim worker As WaitCallback Dim state As Object instance.Start(worker, state)
public void Start( WaitCallback worker, object state )
public: void Start( WaitCallback* worker, Object* state )
public: void Start( WaitCallback^ worker, Object^ state )
This method provides an easy means for executing blocking functions on a worker thread. Applications with a UI thread should use this technique to execute processes (like Connect and Read) that can block the UI thread.
Unhandled exceptions occurring on the worker thread will be caught and reported by the Error event.
private void button1_Click(object sender, EventArgs e) { tcp1.Start(connectWriteRead, null); } private void connectWriteRead(object state) { tcp1.Connect(new TcpSession(new Dart.Sockets.IPEndPoint(myEchoServer, 7))); tcp1.Write("hello world!"); byte[] buffer = new byte[128]; tcp1.Marshal(tcp1.Read(buffer), "", null); tcp1.Close(); } void tcp1_Data(object sender, Dart.Sockets.DataEventArgs e) { textBox1.AppendText(e.Data.ToString()); }
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) tcp1.Start(AddressOf connectWriteRead, Nothing) End Sub Private Sub connectWriteRead(ByVal state As Object) tcp1.Connect(New TcpSession(New Dart.Sockets.IPEndPoint(myEchoServer, 7))) tcp1.Write("hello world!") Dim buffer(127) As Byte tcp1.Marshal(tcp1.Read(buffer), "", Nothing) tcp1.Close() End Sub Private Sub tcp1_Data(ByVal sender As Object, ByVal e As Dart.Sockets.DataEventArgs) textBox1.AppendText(e.Data.ToString()) End Sub