PowerTCP Mail for .NET
Marshal(Data,String,Object) Method
Example 




Data to be marshaled.
Text message to be marshaled.
State information to be marshaled.
Marshals data to the UI thread.
Syntax
Public Overloads Sub Marshal( _
   ByVal data As Data, _
   ByVal message As String, _
   ByVal state As Object _
) 
Dim instance As TcpBase
Dim data As Data
Dim message As String
Dim state As Object
 
instance.Marshal(data, message, state)
public void Marshal( 
   Data data,
   string message,
   object state
)
public: void Marshal( 
   Data* data,
   string* message,
   Object* state
) 
public:
void Marshal( 
   Data^ data,
   String^ message,
   Object^ state
) 

Parameters

data
Data to be marshaled.
message
Text message to be marshaled.
state
State information to be marshaled.
Remarks

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.

Example
This example demonstrates execution of a looping Read on a worker thread, and marshaling the data to the UI.
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
See Also

Reference

TcpBase Class
TcpBase Members
Overload List


PowerTCP Mail for .NET Documentation Version 4.3
© 2018 Dart Communications. All Rights Reserved.
Send comments on this topic