Im using TcpClient to write data to a port.
Using NewtworkStream & BinaryWriter.
All works fine. The only problem im having is that my UI freezes
when the BinaryWriter is sending allot of data from the database.
This is what I have with the binarywriter writer = new BinaryWriter(networkstream)
writer.Write(str);
I treid to add the BackgroundWorker.RunWorkerAsync(writer.Write(str);
This throws an error.
How do I make the writer use a different thread when writing ?
Multi Threading with BinaryWriter
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Matthew CochranRank #252 · 10K reputationPosted Apr 17, 2008, 3:38 PM EDT
all streams have an async method so you can use them like this...
NetworkStream
ns = new NetworkStream(new Socket(new SocketInformation()));ns.BeginWrite(...)
you have to pass in your binary array, so whatever you are writing to the stream will have to be converted before using this call.
Hope this helps,
-Matt