diff --git a/src/Application.cpp b/src/Application.cpp index 2822b2b9..2262ea0d 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -49,8 +49,18 @@ int Application::run(const std::vector& arguments) { this->insight->setApplicationConfig(this->applicationConfig); this->insight->setEnvironmentConfig(this->environmentConfig); this->insight->setInsightConfig(this->insightConfig); - this->insight->run(); - Logger::debug("Insight closed"); + + /* + * Before letting Insight occupy the main thread, process any pending events that accumulated + * during startup. + */ + this->applicationEventListener->dispatchCurrentEvents(); + + if (Thread::getThreadState() == ThreadState::READY) { + this->insight->run(); + Logger::debug("Insight closed"); + } + this->shutdown(); return EXIT_SUCCESS; }