public void OnReceive(IAsyncResult ar)
        {
            UdpState s = new UdpState();

            UdpClient u = (UdpClient)((UdpState)(ar.AsyncState)).u;
            IPEndPoint e = (IPEndPoint)((UdpState)(ar.AsyncState)).e;

            s.u = u;
            s.e = e;

            Byte[] receiveBytes = u.EndReceive(ar, ref e);
            Debug.WriteLine(string.Format("Pen Signal Data : {0}",Encoding.ASCII.GetString(receiveBytes, 0, receiveBytes.Length)));

            if (Encoding.ASCII.GetString(receiveBytes, 0, receiveBytes.Length) == "NONE" )
            {
                gSensor_val = 1;
                //this.Dispatcher.Invoke(new myDelegate(DrawingCanvas_PreviewStylusDownBySensor),1);
                //this.llbTools.SelectedIndex = 1;
            }
            else if (Encoding.ASCII.GetString(receiveBytes, 0, receiveBytes.Length) == "WEAK")
            {
                gSensor_val = 2;
                //this.Dispatcher.Invoke(new myDelegate(DrawingCanvas_PreviewStylusDownBySensor), 2);
            }
            else if (Encoding.ASCII.GetString(receiveBytes, 0, receiveBytes.Length) == "STNG")
            {
                gSensor_val = 3;
                //this.Dispatcher.Invoke(new myDelegate(DrawingCanvas_PreviewStylusDownBySensor), 3);
            }
            else
            {
                gSensor_val = 4;
                //this.Dispatcher.Invoke(new myDelegate(DrawingCanvas_PreviewStylusDownBySensor), 4);
            }

            u.BeginReceive(new AsyncCallback(OnReceive), s);
        }
        private void InitializeUdpSocket()
        {
            IPEndPoint ipep = new IPEndPoint(IPAddress.Any, 9985);
            UdpClient newsock = new UdpClient(ipep);

            UdpState s = new UdpState();

            s.e = ipep;
            s.u = newsock;

            newsock.BeginReceive(new AsyncCallback(OnReceive), s);
        }