public void Main() { try { int counter = 0; DateTime before = DateTime.Now; while (Xbox.Ping(500)) { try { if (!mnuPause.Checked && Video.IsActive) { //ParseUserInput(); // dont bother updating at full speed if minimized, just poll so we don't lose the stream... if (this.WindowState == FormWindowState.Minimized) { System.Threading.Thread.Sleep(1000); } renderWindow.Image = Video.NextFrame(); status.Text = "Frame: " + Video.FrameNumber; // Xbox.GetUInt32(Xbox.GetUInt32(0xB0033DA0)); (presentation frame number) counter++; } // attempt to recreate videostream before breaking out of the loop // the main reason for it becoming inactive is if its paused for more than 5 seconds or so... if (!Video.IsActive && !Video.Restart()) { break; } } catch (Exception) { Xbox.Connect(); Video.Restart(); } Application.DoEvents(); } TimeSpan elapse = DateTime.Now - before; double fps = counter / elapse.TotalSeconds; Xbox.Disconnect(); renderWindow.Image = null; mnuPause.Checked = false; mnuStep.Enabled = false; status.Text = "Disconnected"; } catch (Exception) { } renderWindow.Image = GetDefaultImage(); }
public static bool Ping(int waitTime) { if (RTH_Imports.IsConnected) { switch (connectedDebugType) { case debugType.YeloDebug: if (xboxDebug.Ping(waitTime) != true) { _IsConnected = false; } else { return(true); } break; } } return(false); }