public void recieveChat(PacketChat pack) { Console.WriteLine("Recieved Chat Packet"); form.Invoke((Action)(() => { try { form.showMessage(pack.destinationID, pack.messageText); } catch (Exception e) { Console.WriteLine(e.Message); //MessageBox.Show("No connection to the server"); //form.closeApplicaton(); } })); }
public static void render() { DateTime last = DateTime.Now; DateTime now = last; TimeSpan frameTime = new TimeSpan(10000000 / fps); while (true) { DateTime temp = DateTime.Now; running_fps = .9 * running_fps + .1 * 1000.0 / (temp - now).TotalMilliseconds; now = temp; TimeSpan diff = now - last; if (diff.TotalMilliseconds < frameTime.TotalMilliseconds) { Thread.Sleep((frameTime - diff).Milliseconds); } last = DateTime.Now; form.Invoke(new MethodInvoker(form.Refresh)); } }