I have an Server/Client application and just wanted to address some concerns I have.
It uses TCP/IP sockets to communicate with each other.
My concerns is the following...
I have a section of code that handles a series of commands from the client (this multi-threads for EVERY user that is connected) this can have up to 20-40-60 threads.
I have dedicated thread to handle live chats for users online.
I have another dedicated thread that handles push notifications to the client.
My question is... am I really doing it properly?
I am concerned that if a push notificaiton/chat/client command is processed at the same time, the client will receive the data incorrectly.
In a nutshell (of course hypothetically speaking):
Client Sends Command: "Get-Me-Data"
Push Notification sends to same client: "You_Got_Mail"
Chat Notification sends to same client: "MESSAGE"
I am concerned that client will receieve the data in this manner Get-Me-MESSAGE-Mail-Data-Got
I heard of using SyncLock to prevent this, should I syncLock the client NetworkStream?
Thanks in advance.