Example #1
0
        private void TriggerBgWorkerForQuery(SimpleExportQuery query)
        {
            dataGridView1.DataSource = bindingSource1;
            progressBar1.Visible     = true;
            BackgroundWorker backgroundWorker = new BackgroundWorker
            {
                WorkerSupportsCancellation = true,
                WorkerReportsProgress      = true
            };

            progressBar1.Visible     = true;
            backgroundWorker.DoWork += (o, args) =>
            {
                SimpleExportQuery report = args.Argument as SimpleExportQuery;
                args.Result = report?.DoQuery();
            };
            backgroundWorker.RunWorkerCompleted += (o, args) =>
            {
                DataTable workerResult = (DataTable)args.Result;
                bindingSource1.DataSource = workerResult;
                dataGridView1.Visible     = true;
                progressBar1.Visible      = false;
            };
            backgroundWorker.RunWorkerAsync(query);
        }
Example #2
0
        private void createButton_Click(object sender, EventArgs e)
        {
            ResetComps();
            var sqlFileName         = ((ComboboxItem)exportTablesComboBox.SelectedItem).Value;
            var keyType             = internalRadioButton.Checked ? "Internal" : "External";
            SimpleExportQuery query =
                new SimpleExportQuery(System.IO.Path.GetDirectoryName(Application.ExecutablePath) + sqlFileName, keyTextBox.Text, keyType);

            TriggerBgWorkerForQuery(query);
        }