private void SimConnect_OnRecvSimobjectDataBytype(SimConnect sender, SIMCONNECT_RECV_SIMOBJECT_DATA_BYTYPE data) { Console.WriteLine("SimConnect_OnRecvSimobjectDataBytype"); uint iRequest = data.dwRequestID; uint iObject = data.dwObjectID; if (!lObjectIDs.Contains(iObject)) { lObjectIDs.Add(iObject); } foreach (SimvarRequest oSimvarRequest in lSimvarRequests) { if (iRequest == (uint)oSimvarRequest.eRequest && (!bObjectIDSelectionEnabled || iObject == m_iObjectIdRequest)) { double dValue = (double)data.dwData[0]; oSimvarRequest.dValue = dValue; oSimvarRequest.bPending = false; oSimvarRequest.bStillPending = false; //Force "." as decimal separator to override the machine-specific culture settings NumberFormatInfo nfi = new NumberFormatInfo(); nfi.NumberDecimalSeparator = "."; switch (iRequest) { case 0: latitude = dValue.ToString(nfi); break; case 1: longitude = dValue.ToString(nfi); break; case 2: altitude = dValue.ToString(nfi); break; case 3: speed = dValue.ToString(nfi); break; } } } string gpsString = latitude + "," + longitude + "," + altitude + "," + speed; Console.WriteLine(gpsString); udpsender.SendLocation(gpsString); }