Search code examples
c#multithreadingclient-server

client - server application crashes


I have a client server application. The clients log in an account on my server. The thing is that my server sometimes crashes and although I have all kind of wrapped in a try-catch statement, I get no message.

The server I have implemented is here: simple threaded tcp server.

Did anyone encounter a crash like this? Is there a place that I can find an error log for the app?

I'm kind of desperate, so ANY ideas would be great. Thanks.


Solution

  • The application is possible to crash because of unhandled exceptions even if you have all functions wrapped in try-catch block because of multi-threading operations.

    try
    {
       var t = new Thread(()=>
          {
              Thread.Sleep(5000);
              throw new Exception();
          });
       t.Start();
       //t.Join();
    }
    catch
    {
        //you can't deal with exception here
        //even though you uncomment `t.Join`
        //the application will crash even there is a try-catch wrapped
    }