0

In a simulator I am writing I use SFML and OpenGL to create a visualization with some basic OpenGL based GUI. Now I need to add a File Chooser Dialog. I was wondering if I could use System.Windows.Forms.OpenFileDialog and update it's events dynamically similarly to the way OpenCV allows you to update windows by using cv::waitkey().

Since OpenFileDialog.ShowDialog() does not return until the window is dismissed, all I have to do is somehow close the Dialog by updating it's events.

I would rather not have to call Application.Run() and leave it in the background because my application is already built around a main loop and Application.Run() takes over the main thread.

Josh
  • 63
  • 6

1 Answers1

0

The equivalent call to cv::waitkey is:

Application.DoEvents()

However after reading Use of Application.DoEvents() it appears that Application.DoEvents() is much more fragile then cv::waitkey. It can cause an application to crash if there is no open win form.

Alternative Approach

I decided to switch to GTK# since it lets you process events as they occur by checking whether any events exist in the event queue by calling Gtk.Application.EventsPending(). Then the events can be processed with Gtk.Application.RunIteration() in a while loop like this:

while (Gtk.Application.EventsPending())
{
    Gtk.Application.RunIteration();
}
Community
  • 1
  • 1
Josh
  • 63
  • 6