Dart.Mail Namespace > TcpBase Class > Marshal Method : Marshal(Data,String,Object) Method |
Public Overloads Sub Marshal( _ ByVal data As Data, _ ByVal message As String, _ ByVal state As Object _ )
This method is used to marshal data from a worker thread to the UI thread for typical display purposes. It calls the OnData method, which raises the Data event.
See the SynchronizingObject property for information on updating UI controls in your event handler.
private void button1_Click(object sender, EventArgs e) { myComponent.Start(readLoopWorker, null); } private void readLoopWorker(object state) { byte[] buffer = new byte[1024]; Data data = myComponent.Read(buffer); while (data != null) { myComponent.Marshal(data, "", null); data = myComponent.Read(buffer); } myComponent.Close(); } void myComponent_Data(object sender, Dart.Sockets.DataEventArgs e) { textBox1.AppendText(e.Data.ToString()); }
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) myComponent.Start(AddressOf readLoopWorker, Nothing) End Sub Private Sub readLoopWorker(ByVal state As Object) Dim buffer(1023) As Byte Dim data As Data = myComponent.Read(buffer) Do While data IsNot Nothing myComponent.Marshal(data, "", Nothing) data = myComponent.Read(buffer) Loop myComponent.Close() End Sub Private Sub myComponent_Data(ByVal sender As Object, ByVal e As Dart.Sockets.DataEventArgs) textBox1.AppendText(e.Data.ToString()) End Sub