public void BroadcastPosition() { udp.Connect("192.168.1.103", 49002); string basePacket = "XGPSSimulator,"; new Thread(() => { Thread.CurrentThread.IsBackground = true; while (true) { playerPos = FSUIPCConnection.GetPositionSnapshot(); //Populate positional variables alt = (Decimal)playerPos.Altitude.Feet; FsLatLonPoint location = playerPos.Location; lat = (Decimal)location.Latitude.DecimalDegrees; lon = (Decimal)location.Longitude.DecimalDegrees; hdg = (Decimal)playerPos.HeadingDegreesTrue; FSUIPCConnection.Process(); groundSpeed.Reconnect(); spd = groundSpeed.GetValue <UInt32>(); spd = spd / 65536; spd = spd * 3600; spd = spd / 1852; alt = Decimal.Round(alt, 1); lat = Decimal.Round(lat, 3); lon = Decimal.Round(lon, 3); hdg = Decimal.Round(hdg, 2); //Assemble a packet string packetToSend = basePacket + lon.ToString() + "," + lat.ToString() + "," + alt.ToString() + "," + hdg.ToString() + "," + spd.ToString() + ".0"; byte[] sendMe = Encoding.ASCII.GetBytes(packetToSend); //Broadcast via UDP udp.Send(sendMe, sendMe.Length); //Pause the thread to allow for the one second gap required by foreflight. Thread.Sleep(990); //Only 990 to allow for processing time. } }).Start(); }