Managing Ports and Transfers in .NET internal static void WriteCompleted( IAsyncResult ar )
{
String msg;
WriteToComPortDelegate deleg;
Boolean success;
// To obtain the msg value passed to the BeginInvoke method,
// cast BeginInvoke's IAsyncResult value to an AsyncResult object
// and get the object's AsyncDelegate property.deleg = (WriteToComPortDelegate)((AsyncResult)ar).AsyncDelegate;// The msg value is in the AsyncState property.msg = (String)ar.AsyncState;// The EndInvoke method returns the value returned by WriteToComPort.success = WriteToComPortDelegate1.EndInvoke(ar);
Console.WriteLine("Write operation began: " + msg);
Console.WriteLine("Write operation succeeded: " + success);
}
An application can call the delegate multiple times, queuing more data in the
transmit buffer with each call. 8  
6
33
83 
The WriteBufferSize property sets the size of the transmit buffer with a mini-
mum size of 2048 bytes. To enable writing more bytes at once to a port for
transmitting, increase the size of the transmit buffer.