CaptureToBitmap with multiple displaySetting

Hi,
got some trouble to capture a view with different display settings…Basically I loop through all existing display settings and use CaptureToBitmap.

But for some reason the CaptureToBitmap doesn’t capture all display settings
It seems the change of display setting is to fast for the CaptureToBitmap…
Any help?

thx

string mydir = @"C:\";

Rhino.Display.RhinoView view = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView;
for (int i = 0; i < Rhino.Display.DisplayModeDescription.GetDisplayModes().Count(); i++)
{
  view.ActiveViewport.DisplayMode = Rhino.Display.DisplayModeDescription.GetDisplayModes()[i];
  view.Redraw();

  var bitmap = doc.Views.ActiveView.CaptureToBitmap(new Size(400, 400), false, false, false);
  var file_name = System.IO.Path.Combine(mydir, Convert.ToString(i + ".jpg"));

  bitmap.Save(file_name);
  bitmap.Dispose();
}

Maybe use a RhinoApp.Wait() in between the re-draw and the capture?

Or wait for the RhinoApp.Idle event to be triggered after the redraw.

Thanks! RhinoApp.Idle seems the one I was looking for.