/// <summary> /// Reads from serial and UDP and process's /// </summary> private void mainloop() { System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US"); System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); threadrun = 1; EndPoint Remote = (EndPoint)(new IPEndPoint(IPAddress.Any, 0)); byte mode = 0; Int16 command = 0; msg_location loc = new msg_location(); while (threadrun == 1) { if (SimulatorRECV.Available > 0) { udpdata = new byte[udpdata.Length]; int recv = SimulatorRECV.ReceiveFrom(udpdata, ref Remote); try { RECVprocess(udpdata, recv); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Xplanes Data Problem - You need DATA IN/OUT 3, 18, 19, 20\n" + ex.Message + "\n"); } } System.Threading.Thread.Sleep(5); // try minimise delays } }