开发者

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 despe开发者_运维百科rate, so ANY ideas would be great. Thanks.


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
}


Have you kept this part of the example code? Add a Console.WriteLine right after the catch...

 catch
    {
      //a socket error has occured
      break;
    }


If you're running under Debug mode in Visual Studio, you might consider enabling CLR Exceptions to propagate to user control. I believe they're disabled by default, which sometimes causes hung applications without any debugger feedback. This article on MSDN might be of interest.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜