I have some problems with System.NullReferenceException. When server do things and we first check user is not null and then he disconnect and server progress something and it try get user comes System.NullReferenceException. I have over 20 000 lines code so i need something small not like allways check is it null.. My server is multithread so sockets get connections and disconnects users alltime on backround so thats why this comes.. I want stop that progress when user disconnect. If i put everywhere "try/catch" is that goodway?
Example:
if (User != null)
{
//do some things
System.Threading.Thread.Sleep(1000); //now we have time disconnect (This only for get error)
User.SendMessage("crash"); //<-- System.NullReferenceException... -.-
}