The problem is that if I call this method too often the message gets merged. For example I loop this method 10 times and each time I want to send single message "Hello". However the final result is "HelloHelloHelloHello...". If I pause the thread for some time
(Thread.Sleep(10)) it works fine but I'm wondering why this happens and is there better way to fix it?

However one way to fix this would be adding some kind of suffix to the end of the message, like EOM. When the server gets the message, it would be something like this:

helloEOMhelloEOMhelloEOM

or if we send something else:

hiEOMhelloEOMHowdyEOM

It could split the message using EOM as the separator and get the final result:

hi
hello
Howdy

This would be one way to fix the problem. However I don't understand why the NetworkStream does not send the message immediately. It seems that it waits a little bit until someone calls the SendMessage method again and it just adds the new message to the
end of the old message and then sends it. And the result is OldmessageNewmessage :/