/// <summary>
        /// Sendings this instance.
        /// </summary>
        private void SwitchSending()
        {
            //try
            //{
            while (!this.Client.Connected)
            {
                Thread.SpinWait(100);
            }

            NetworkStream stream = this.Client.GetStream();
            char[] splitOpt = { ',' };
            String[] dstMsg;
            WriteStream caller = new WriteStream(ParentNode.WriteToNetworkStream);
            bool resend = true;

            while (this.toSend.Count > 0)
            {

                lock (this.toSend)
                {
                    dstMsg = this.toSend.Dequeue().Split(splitOpt, 2);
                }

                SwitchMessage msg = new SwitchMessage();
                msg.EncodeMessage(dstMsg[0], this.ParentNode.Name, dstMsg[1]);
                //Console.WriteLine(" : " + msg.Info + " : Node " + this.name + " is sending to Node " + dstMsg[0] + " this message " );
                while (resend)
                {
                    lock (stream)
                    {
                        if (stream.CanWrite)
                        {
                            caller.BeginInvoke(stream, msg, null, null);
                        }
                        else
                        {
                            Console.WriteLine("Node " + this.ParentNode.Name + " cannot write via switch.");
                        }
                    }
                    try
                    {
                        //Sleep until an ack is recieved.
                        Thread.Sleep(10000);

                    }
                    catch (ThreadInterruptedException)
                    {
                        resend = false;
                    }

                    if(this.doneSending == true)
                    {
                        resend = false;
                    }
                }
                resend = true;

                if (this.doneSending == true)
                {
                    break;
                }
            }

            //Console.WriteLine("Sender thread for node " + this.name + " exiting.");

            SwitchMessage done = new SwitchMessage();
            done.EncodeHiddenComm(GlobalConst.serverName, GlobalConst.serverName);
            this.doneSending = true;

            while (stream.CanWrite)
            {
                try
                {
                    stream.Write(done.ToSend, 0, done.ToSend.Length);
                    Thread.Sleep(1000);
                }
                catch (System.IO.IOException)
                {
                    break;
                }
                catch (ThreadInterruptedException)
                {
                    ;
                }
            }
        }