private void StreamData()
        {
            while (stream)
            {
                if (dongleConnected)
                {
                    dongleMessageMutex.WaitOne();
                    dongleLastMessage = myFtdiDevice.getLastMessage();
                    dongleMessageMutex.ReleaseMutex();
                }
                else
                    connectDongle();

                if (clientConnected)
                {
                    if (dongleLastMessage!= null)
                    {
                        Send(dongleLastMessage.ToByteArray());
                        dongleLastMessage = null;
                    }
                }
                Thread.Sleep(1000 / outputDataRate);
            }
            if (clientConnected)
            {
                myHandler.Shutdown(SocketShutdown.Both);
                myHandler.Close();
            }
        }
 public void setMessage(Message m)
 {
     dongleMessageMutex.WaitOne();
     dongleLastMessage = m;
     dongleMessageMutex.ReleaseMutex();
 }