def run(self):
        """ Run the model synchronously.
        Shows a modal dialog until the run completes.
        Returns the dialog.
        """
        runner = self.runner
        gui_handler = lambda *args: deferred_call(self.handle_error, *args)
        runner.error_handler = gui_handler
        dialog = RunDialog(parent=self.parent,
                           title='Running model...',
                           text='Please wait while the model runs.')
        dialog.observe('rejected', lambda change: runner.cancel())
        dialog.show()
        event_loop = QtCore.QEventLoop()
        timer = QtCore.QTimer()

        def start_run():
            runner.run()
            timer.setInterval(50)
            timer.timeout.connect(check_loop)
            timer.start()

        def check_loop():
            dialog.output = runner.output()
            if not runner.running:
                timer.stop()
                event_loop.quit()

        timed_call(50, start_run)
        event_loop.exec_()
        dialog.accept()
        return dialog