private Database GetDatabase() { ReportStatus("Retrieving the source database's schema..."); Database database = null; Exception exception = null; var worker = new Thread(() => { try { database = SchemaProvider.GetDatabase(Utility.GetRealProviderName(sourceProviderName), sourceConnectionString); foreach (string tableName in selectedTableNames) { database.Tables[tableName].Checked = true; } } catch (Exception ex) { Console.WriteLine(ex); exception = ex; } }); worker.Start(); while (worker.IsAlive) { Application.DoEvents(); Thread.Sleep(WORKER_THREAD_DELAY); } if (exception != null) { throw exception; } return(database); }