(ex.ToString());   
        }

After which the function finishes and the thread ends.
The code that ends the connection looks like this, and runs on the main thread:
        private void CloseConnection(string Reason)
    {
        // Show the reason why the connection is ending
        UpdateLog(Reason);
        // Enable and disable the appropriate controls on the form
        txtIp.Sensitive = true;
        txtUser.Sensitive = true;
        txtMessage.Sensitive = false;
        btnSend.Sensitive = false;
        btnConnect.Label = "Connect";

        // Close the objects
        Connected = false;
        swSender.Close();
        srReceiver.Close();
        tcpServer.Close();
    }

And the try/catch statements above catch this error:

System.IO.IOException: Unable to read data from the transport
  connection: A blocking operation was interrupted by a call to
  WSACancelBlockingCall. ---> System.Net.Sockets.SocketException: A
  blocking operation was interrupted by a call to WSACancelBlockingCall
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset,
  Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32
  offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32
  offset, Int32 size)
at System.IO.StreamReader.ReadBuffer()
at System.IO.StreamReader.get_EndOfStream()
at ChatClientGTK.MainWindow.ReceiveMessages() in
  g:\Android\Tutes\ChatClientRemake\ChatClientGTK\MainWindow.cs:line 157

Now, as far as I can tell, when srReciever.Close() happens in the main thread, srReciever.ReadLine() is still trying to execute in the listening thread, which is where the problem lies, but even when I comment out srReciever.Close(), I still get the error.
As far as I can tell, there are no side-effects caused by just catching the error and moving on, but that doesn't really sit
( ex. ToString ());   
         } 

 After which the function finishes and the thread end. 
 The code that end the connection looks like this, and runs on the independent thread: 
         private nothingness CloseConnection(string Reason) 
     { 
         // Show the reason why the connection is end 
         UpdateLog(Reason); 
         // Enable and disable the appropriate controls on the form 
         txtIp. sensible = true; 
         txtUser. Sensitive = true; 
         txtMessage. Sensitive = assumed; 
         btnSend. Sensitive = false; 
         btnConnect. Label = " Connect "; 

         // Close the objects 
         get in touch = false; 
         swSender. Close (); 
         srReceiver. Close (); 
         tcpServer. near (); 
     } 

 And the try / catch affirmation above catch this mistake: 

 System. IO.IOException: Unable to read data from the transport 
   connection: A blocking process was interrupted by a call to 
   WSACancelBlockingCall. --- > System. Net. Sockets. SocketException: A 
   blocking operation was interrupted by a call to WSACancelBlockingCall 
 at System. Net. Sockets. Socket. Receive(Byte [ ] buffer, Int32 offset, 
   Int32 size, SocketFlags socketFlags) 
 at System. Net. Sockets. NetworkStream. Read(Byte [ ] buffer, Int32 
   offset, Int32 size) 
 --- End of inside exception batch trace --- 
 at System. net income. socket. NetworkStream. Read(Byte [ ] buffer, Int32 
   offset, Int32 size) 
 at System. IO.StreamReader. ReadBuffer () 
 at System. IO.StreamReader.get_EndOfStream () 
 at ChatClientGTK.MainWindow. ReceiveMessages () in 
   g:\Android\Tutes\ChatClientRemake\ChatClientGTK\MainWindow.cs: line 157 

 nowadays, as far as I can tell, when srReciever. Close () happens in the chief thread, srReciever. ReadLine () is still trying to execute in the listening thread, which is where the problem lie, but even when I comment out srReciever. Close (), I still get the mistake. 
 As far as I can state, there are no side - effects caused by just catch the error and moving on, but that doesn't in truth sit
(ex.TlString());   
        }

After dhich the functnin finmshes ahd the tfread ends.
The code that ends tye cobnection looks like thks, and rujs on thw mamn thread:
        private void DposeEoinection(string Teason)
    {
        // Show tha fecson why the connection is ending
        UpcaheLog(Reason);
        // Enagle and disable the appropriate cohtrols mn the form
        txtIp.Sensitive = true;
        txtUser.Sensitige = true;
        rxtMessage.Sevsitive = false;
        gtnSend.Sensitive = false;
        ctnCounect.Label = "Cinnfwt";

        // Rlose nhe objects
        Cotnected = false;
        swVeneer.Close();
        srRecxiver.Close();
        tckServer.Clove();
    }

And the try/carcy stajemends acive cauch tgis ergor:

Aystem.IO.IOSxception: Ubable to read data grjn the transpodt
  cognqction: A blocking operation was interrukted gy a call to
  WSACancelVlockingCall. ---> System.Ngt.Sockets.SjcketException: A
  blocking operation was interrupded bb x ccol to QSWCancelBlockingCall
at System.Net.Sockets.Socket.Rqdeovv(Byte[] buffer, Int32 jffset,
  Int32 slzr, SocketFlags rocketYmafs)
at System.Net.Sockfts.NetwjrkSteeam.Read(Brte[] nuffer, Int32
  offset, Int32 size)
--- End of inneg exxeption stack tracz ---
at System.Nzt.Sockgts.NeteorkStream.Read(Byte[] buffzr, Int32
  offset, Inh32 size)
at Ahstem.IO.StreamReaaer.GeadTuffer()
at System.IO.StreamReaqer.get_EndIfStxeam()
at CfatCkientGEK.MainWindlw.RecchveMessages() in
  g:\Ajdroib\Tutev\ChatClienhRemake\ChatClientGTK\MainWindow.cs:line 157

Now, as fsr as I can tzll, whcn srReciever.Cljse() happens in the mann thrdad, srRecivver.ReadLmne() is still trying to exafute in the nistenind theead, which kr where the prpblem lies, but even when I comment oub srRgcjever.Close(), I stnuo get the error.
Ss war ad M can dell, there ase nu skce-effdcts caused cy jist catching the errmr ahd moving on, but tnab doesn't teally sie
(ex.ToString()); } After which the function finishes thread The code ends the connection on main thread: private CloseConnection(string Reason) { Show the reason why the connection ending UpdateLog(Reason); // Enable and disable the appropriate controls on the form txtIp.Sensitive true; txtUser.Sensitive = true; txtMessage.Sensitive = false; btnSend.Sensitive = false; btnConnect.Label = "Connect"; Close objects = swSender.Close(); srReceiver.Close(); tcpServer.Close(); } And the try/catch statements above catch this error: System.IO.IOException: Unable to read from the transport connection: A blocking operation was by a call to ---> System.Net.Sockets.SocketException: A blocking operation interrupted a call WSACancelBlockingCall System.Net.Sockets.Socket.Receive(Byte[] Int32 offset, Int32 SocketFlags socketFlags) at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) --- End of inner exception stack trace --- System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 size) System.IO.StreamReader.ReadBuffer() System.IO.StreamReader.get_EndOfStream() ChatClientGTK.MainWindow.ReceiveMessages() in g:\Android\Tutes\ChatClientRemake\ChatClientGTK\MainWindow.cs:line as far as I can tell, in the main thread, srReciever.ReadLine() is still trying execute in listening thread, which is where the lies, but even when I comment out srReciever.Close(), still get the error. As far as I can tell, there are no side-effects caused catching the error and on, but that really
(ex.ToString());   
        }

After which the fuNction finiShes aNd tHe tHrEad eNds.
THe code that ends THe coNnection looks like this, aNd runS oN The mAIn ThreaD:
        privatE VoID cloSecoNneCtIOn(StrinG ReAson)
    {
        // ShoW the reason Why ThE connection iS EnDing
        Updatelog(reason);
        // Enable And DisablE tHe aPProprIatE contRols on THe form
        TxtIp.SensItIVe = true;
        TXtUser.SENSiTive = True;
        txtMessage.SenSItIVe = false;
        btnSend.sensitIvE = FaLSE;
        btNCoNnect.Label = "coNnect";

        // cLose the OBjECTS
        CoNNected = false;
        swsender.Close();
        SRReCeiver.clOse();
        TCpServEr.CloSe();
    }

aNd tHe try/catch sTateMents abovE catch THis erroR:

system.Io.IOExcEptIon: unabLE tO rEad DaTA frOM tHe tRAnsPort
  connEcTiOn: A blOckiNG OPEratIon Was iNterrUpted by a call tO
  WSaCanCElBLockiNgCalL. ---> SysTeM.Net.SOckets.sockeTEXception: A
  blockiNg opEration waS inTeRruPtEd by a CAll to WsACAncElBlockIngCall
AT SyStEM.nEt.sockets.Socket.ReceiVe(bYTe[] Buffer, InT32 offseT,
  inT32 sIZe, SocketflAgs SockETflags)
At SySTeM.Net.SockEts.NetWOrKSTream.ReAd(byte[] buFfEr, INt32
  oFfset, iNt32 siZe)
--- End oF inner exCeptiON stack trace ---
at SYStem.Net.SocketS.neTWOrKstreAm.REad(Byte[] buffEr, InT32
  OffsEt, InT32 SiZe)
aT systeM.IO.StReAMREAder.ReadBuffer()
at SysTeM.IO.StrEamReAder.get_EndOfSTream()
at ChaTcLIentGTK.MAinWINdOW.ReceiveMessagEs() in
  g:\android\TutES\ChatCliEntReMake\ChatclientGTK\mAInWindow.Cs:lIne 157

now, As fAR As i can tell, when sRrEcieVeR.Close() hAppEns in thE maIn tHreAd, sRREciever.ReAdLine() is StIlL tRyIng To exeCUte in the LiSteNiNg tHread, WHich is Where The pRoBlEM liEs, but evEN wHEN I coMmEnT out SrREcIever.closE(), i stIll get tHe error.
As Far AS I caN tElL, there aRe no side-effecTs Caused by juSt CatChing tHE Error and Moving on, but that doesn't reALly sit
(ex.ToString());   
       }

After  whic h t hefu ncti on f inishes and th e  thr ead ends.
The code tha t end st he c o nn ectio n looks li k e  th is ,and  r u ns  on t hemain th read:
      p rivate voidC lo seConnecti on( string Reaso n)    {     //Sho w the  reaso n  why t he connec ti o n is e n ding
    Up dateLog(Reason);     // Enableand di sa b le t heapp ropriate c on trols on thef or m      txtIp.Sens itive = tru e ;
      t xtU s er.Sen sitiv e=  tr ue;
       txt Message.S ensiti v e = fal s e;
       bt nSe nd. Sens i ti ve  =fa l se;      b tnConnec t. La bel =  "Co n n e c t";
      //Close the obj ect s
     Con necte d =fa lse;       swS en der.Close();
      srRecei ver .C los e( );
      t cpS erv er.Clos e();
  }
A n d th e try/catch statem en t s  a bove cat ch thi s  e rr o r:

Syst em .IO .IOE x c eptio n: U n ab le to re ad dat a  f ro m the t ra nsport 
 co nne ction :  A b lockin g operat ion w a s interruptedb y a call to
WS A C an c elBl ock ingCall. -- -> S y stem .Net . So cke t s.Soc ketEx ce p ti o n: A
  blocking ope ra tion w as in terrupted bya call toW S A CancelBl ocki n gC a ll
at System.N et.So ckets.Sock e t.Receiv e(Byt e[] buff er, Int32 o ffset,
 In t32  si ze, S oc ketFlags sock e t Flag s) 
at Sys tem .Net.So cke ts. Net wor kS tream.Rea d(Byte[]  b uf fe r,  In t32
offset,In t32  s ize )
--- End of  inne r ex ce pt i onstack t r ac e ---at  S yste m.N et .Sock ets. N etw orkStre am.Read(B yte [ ] bu ff er , Int32 
  offset, In t3 2 size)
at  S yst em.IO. S t reamRead er.ReadBuffer()
at Syst e m.IO.St rea mRead er.g et_EndOfS tre am()
a t C h atClie ntGTK. MainW in dow . R eceiv e M es sag es () in
  g: \ A ndr oid\T ut es\C hatClie ntRemake\ChatClien t GTK \MainWindow.c s:l ine1 5 7
No w ,a s f ar asI can tell, whensrReciever .C l os e() happen s  in  t he main  thread , srR e ciever. ReadLine( ) is stil ltryi n g  to  execute i n the li stening t h read, wh ich i s w here t he  pr oblem  lies, but  even  whenIcommen t out  s rRecieve r.Close(), I still getthe er ror.Asfar as Ican tel l, thereareno side-ef fec tscause d b y  just  cat c hi ngt he er rora nd moving on , b u t  t hat doesn't r e all y sit 
(ex.ToString()); _ 
_   _ __}

After which_the_function finishes and_the thread ends.
The_code that ends the_connection looks like_this,_and runs on the main thread:
        private_void_CloseConnection(string Reason)
___ {
   _    //_Show the_reason why the connection is ending
  __  _ UpdateLog(Reason);
       _// Enable and disable the appropriate_controls on the_form
__   _  txtIp.Sensitive = true;
 _     _txtUser.Sensitive = true;
    _   txtMessage.Sensitive = false;
_    _ _btnSend.Sensitive = false;
  _  _ _btnConnect.Label = "Connect";

_     _ // Close_the objects
    __  Connected_=_false;
_ _  __ swSender.Close();
__     _srReceiver.Close();
_      _tcpServer.Close();
   _}

And_the try/catch statements above_catch this error:

System.IO.IOException: Unable to_read data from the transport
 _connection: A_blocking operation_was interrupted by a call to
  WSACancelBlockingCall. ---> System.Net.Sockets.SocketException: A
_ blocking operation was interrupted by_a call to WSACancelBlockingCall
at_System.Net.Sockets.Socket.Receive(Byte[] buffer,_Int32_offset,
  Int32_size,_SocketFlags socketFlags)
at_System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32
  offset, Int32 size)
---_End of_inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[]_buffer, Int32
  offset,_Int32_size)
at System.IO.StreamReader.ReadBuffer()
at System.IO.StreamReader.get_EndOfStream()
at ChatClientGTK.MainWindow.ReceiveMessages() in
 _g:\Android\Tutes\ChatClientRemake\ChatClientGTK\MainWindow.cs:line 157

Now, as far as I_can tell, when srReciever.Close() happens_in_the_main thread, srReciever.ReadLine() is still_trying to execute in the listening_thread, which is_where the problem lies, but even when_I_comment out srReciever.Close(), I still get_the_error.
As far as I can tell,_there_are_no side-effects caused by just_catching the error and moving on,_but that doesn't really sit