I develop application with two main option grouped by groupBox in main form. First option is run server with specific behaviour for example I choose TCP protocol, type IP address, port number and atfter that I click run button which generate independent forms with this specific server. Second option is client which is analogous to first option. Client and server can send/receive information to via sockets.

My question is what is proper way to build this application? I try to put every server and client to independent thread but I wonder is it a good solution because I find similar question where there is no multithread answer.

  • Why make it more difficult than it has to be. If I where you, I'd take a look at a toolkit such as NancyFX which is designed specifically for adding this kind of behavior to a stand alone application. As for the outgoing calls, some simple code using the standard .NET httpclient (Available in System.Net) assemblies will alow you to make requests to the server side.
    – shawty
    Commented May 11, 2015 at 22:43

1 Answer 1


Edit: I see that the post is old, however I'll toss the answer up anyways.

In my humble opinion, I think the proper way would be to design this in three pieces.

  1. Server.cs - the logic that behind the server
  2. Client.cs - the logic that behind the client
  3. Your UI.

You would only need two threads, one that the UI runs on which you don't have to worry about and one that either the Server or Client runs on (which you do have to worry about). You have two ways to handle the multi-threaded work. Either on the UI (checking for cross-thread business, invoking, etc) or in the class it self. I personally prefer the latter.

Food for thought:

I personally like to trigger events which the UI can subscribe to and react accordingly. I tend to use AsyncOperation.Post() to handle the cross-threaded stuff. Look into this: https://msdn.microsoft.com/en-us/library/system.componentmodel.asyncoperation.post(v=vs.110).aspx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.