private void ExceptionHandler(SharpDXException ex) { if (ex.ResultCode == ResultCode.NotAcquired || ex.ResultCode == ResultCode.InputLost) { try { Joystick.Acquire(); } catch (Exception) { /* Ignored */ } } }
public bool PerformResetOnException(SharpDXException ex) { if (ErrorHelpers.ShouldResetDxgiForError(ex.Descriptor)) { this.m_d3D?.Destroy(); return(true); } return(false); }
public static void Error(Exception ex) { if (ex is SharpDXException) { SharpDXException sharpDxException = (SharpDXException)ex; Debug.Trace("Error Code -> {0}", (object)sharpDxException.ResultCode.ToString()); Debug.Trace("Error String -> {0}", (object)((object)sharpDxException.Descriptor).ToString()); } Debug.Trace("Type -> {0}", (object)ex.GetType()); Debug.Trace("Message -> {0}", (object)ex.Message); Debug.Trace("Source -> {0}", (object)ex.Source); Debug.Trace("Target -> {0}", (object)ex.TargetSite); Debug.Trace("Inner -> {0}", (object)ex.InnerException); Debug.Trace("Stack ->"); Debug.Trace(ex.StackTrace); }
void LogStuff(SharpDXException e) { if (MyRenderProxy.Log == null) { return; } MyRenderProxy.Log.WriteLine("Reason: " + e.Message.Trim()); if (e.Descriptor == SharpDX.DXGI.ResultCode.DeviceRemoved) { MyRenderProxy.Log.WriteLine("Reason: " + MyRender11.Device.DeviceRemovedReason); } MyRenderProxy.Log.WriteMemoryUsage(""); MyRenderProxy.Log.WriteLine("Buffer type name: " + GetType().Name); MyRenderProxy.Log.WriteLine("Buffer debug name: " + Name); MyRenderProxy.Log.WriteLine("Buffer description:\n" + BufferDescriptionToString()); MyRenderProxy.Log.WriteLine("Exception stack trace: " + e.StackTrace); StringBuilder sb = new StringBuilder(); System.Threading.Thread.Sleep(1000); foreach (var column in MyRenderStats.m_stats.Values) { foreach (var stats in column) { sb.Clear(); stats.WriteTo(sb); MyRenderProxy.Log.WriteLine(sb.ToString()); } } MyStatsUpdater.UpdateStats(); MyStatsDisplay.WriteTo(sb); MyRenderProxy.Log.WriteLine(sb.ToString()); }
public void DeviceExceptionDialog(int state, SharpDXException ex, SharpDXException ex2, AccessViolationException ex3 = null) { String error = "No Error. OH-NO!"; String error2 = ""; String errorCode = "404 (No Error Code Given)"; String errorCode2 = "404 (No Secondary Error Code Given)"; if (ex != null) { error = ex.ToString(); errorCode = ex.ResultCode.ToString(); } else if (ex3 != null) { error = ex3.ToString(); errorCode = ex3.HResult.ToString(); } if (ex2 != null) { error2 = ex2.ToString(); errorCode2 = ex2.ResultCode.ToString(); } if (state == 0) { using (var deviceLostBox = new DeviceLostBox(error, error2, errorCode, errorCode2)) { deviceLostBox.ShowDialog(); deviceExceptionResult = deviceLostBox.DialogResult; } if (deviceExceptionResult == DialogResult.Yes) //Yes and Exit { Editor.Instance.backupSceneBeforeCrash(); Environment.Exit(1); } else if (deviceExceptionResult == DialogResult.No) //No and try to Restart { DisposeDeviceResources(); Init(Editor.Instance); } else if (deviceExceptionResult == DialogResult.Retry) //Yes and try to Restart { Editor.Instance.backupSceneBeforeCrash(); DisposeDeviceResources(); Init(Editor.Instance); } else if (deviceExceptionResult == DialogResult.Ignore) //No and Exit { Environment.Exit(1); } } else if (state == 1) { using (var deviceLostBox = new DeviceLostBox(error, error2, errorCode, errorCode2, 1)) { deviceLostBox.ShowDialog(); deviceExceptionResult = deviceLostBox.DialogResult; } if (deviceExceptionResult == DialogResult.Yes) //Yes and Exit { Editor.Instance.backupSceneBeforeCrash(); Environment.Exit(1); } else if (deviceExceptionResult == DialogResult.No) //No and try to Restart { DisposeDeviceResources(); Init(Editor.Instance); } else if (deviceExceptionResult == DialogResult.Retry) //Yes and try to Restart { Editor.Instance.backupSceneBeforeCrash(); DisposeDeviceResources(); Init(Editor.Instance); } else if (deviceExceptionResult == DialogResult.Ignore) //No and Exit { Environment.Exit(1); } } }
/// <summary> /// Attempt to recover the device if it is lost. /// </summary> public void AttemptRecovery(SharpDXException ex) { if (_device == null) { return; } Result result = _device.TestCooperativeLevel(); if (result == ResultCode.DeviceLost) { //try //{ Debug.Print("Device Lost! Fixing...."); DisposeDeviceResources(); InitDeviceResources(); deviceLost = false; //} //catch (SharpDXException ex2) //{ DeviceExceptionDialog(0, ex, null); //} } else if (result == ResultCode.DeviceRemoved) { //try //{ Debug.Print("Device Removed! Fixing...."); ResetDevice(); deviceLost = false; //} //catch (SharpDXException ex2) //{ DeviceExceptionDialog(0, ex, null); //} } else if (result == ResultCode.OutOfVideoMemory) { Debug.Print("Out of Video Memory!"); DeviceExceptionDialog(1, ex, null); } else if (result == ResultCode.DeviceNotReset) { try { deviceLost = true; Debug.Print("Device Not Reset! Fixing...."); DisposeDeviceResources(); InitDeviceResources(); Init(Editor.Instance); Editor.Instance.DisposeTextures(); deviceLost = false; } catch (SharpDXException ex2) { DeviceExceptionDialog(0, ex, ex2); } } else { DeviceExceptionDialog(0, ex, null); } }