/// <summary> /// Displays a printable. /// </summary> /// <param name="c"> The printable to be displayed. </param> /// <ramarks> Calls to this method are synchronized, i.e. it will finish displaying one printable before displaying the next. </remarks> public void UpdateSync(IPrintable c) { // We have an additional UI update Interlocked.Increment(ref workCounter); //Must run on the main (UI) thread if (InvokeRequired) { Invoke((MethodInvoker) delegate { uiUpdateTimer.Start(); }); } else { uiUpdateTimer.Start(); } lock (this) { // During debugging we want VS to catch exceptions so we can inspect the program state at the point where the exception was thrown. // For release builds we catch the execption here and display a message so the user knows that that they shouldn't wait for the generalization. #if !DEBUG try { #endif DisplayMessage("busy..."); // Update var content = new InfoPanelContent(); c.InfoPanelText(content, getFormatFromGUI()); content.finalize(); currentInfoPanelPrintable = c; infoPanelQueue.Enqueue(content); #if !DEBUG } catch (Exception e) { // Notify user Interlocked.Decrement(ref workCounter); DisplayMessage($"An exception was thrown. Please report this bug to [email protected].\nDescription of the exception: {e.Message}"); Console.WriteLine(e); } #endif } }