private void ImportDatasetObject(object datasetObject, bool schemaOnly)
        {
            if (datasetObject is IFeatureDataset)
            {
                IFeatureDataset dataset = (IFeatureDataset)datasetObject;
                foreach (IDatasetElement element in dataset.Elements)
                {
                    if (element is IFeatureLayer)
                    {
                        ImportDatasetObject(((IFeatureLayer)element).FeatureClass, schemaOnly);
                    }
                }
            }
            if (datasetObject is IFeatureClass)
            {
                Thread thread = new Thread(new ParameterizedThreadStart(ImportAsync));

                if (_import == null)
                {
                    _import = new FDBImport();
                }
                else
                {
                    MessageBox.Show("ERROR: Import already runnung");
                    return;
                }
                _import.SchemaOnly = schemaOnly;
                FeatureClassImportProgressReporter reporter = new FeatureClassImportProgressReporter(_import, (IFeatureClass)datasetObject);

                FormProgress progress = new FormProgress(reporter, thread, datasetObject);
                progress.Text = "Import Featureclass: " + ((IFeatureClass)datasetObject).Name;
                progress.ShowDialog();
                _import = null;
            }
            if (datasetObject is FeatureClassListViewItem)
            {
                Thread thread = new Thread(new ParameterizedThreadStart(ImportAsync));

                if (_import == null)
                {
                    _import = new FDBImport();
                }
                else
                {
                    MessageBox.Show("ERROR: Import already runnung");
                    return;
                }
                _import.SchemaOnly = schemaOnly;
                FeatureClassImportProgressReporter reporter = new FeatureClassImportProgressReporter(_import, ((FeatureClassListViewItem)datasetObject).FeatureClass);

                FormProgress progress = new FormProgress(reporter, thread, datasetObject);
                progress.Text = "Import Featureclass: " + ((FeatureClassListViewItem)datasetObject).Text;
                progress.ShowDialog();
                _import = null;
            }
        }
        async private Task ImportDatasetObject(object datasetObject, bool schemaOnly)
        {
            if (datasetObject is IFeatureDataset)
            {
                IFeatureDataset dataset = (IFeatureDataset)datasetObject;
                foreach (IDatasetElement element in await dataset.Elements())
                {
                    if (element is IFeatureLayer)
                    {
                        await ImportDatasetObject(((IFeatureLayer)element).FeatureClass, schemaOnly);
                    }
                }
            }
            if (datasetObject is IFeatureClass)
            {
                if (_import == null)
                {
                    _import = new FDBImport();
                }
                else
                {
                    MessageBox.Show("ERROR: Import already runnung");
                    return;
                }
                _import.SchemaOnly = schemaOnly;
                FeatureClassImportProgressReporter reporter = await FeatureClassImportProgressReporter.Create(_import, (IFeatureClass)datasetObject);

                FormTaskProgress progress = new FormTaskProgress(reporter, ImportAsync(datasetObject));
                progress.Text = "Import Featureclass: " + ((IFeatureClass)datasetObject).Name;
                progress.ShowDialog();
                _import = null;
            }
            if (datasetObject is FeatureClassListViewItem)
            {
                if (_import == null)
                {
                    _import = new FDBImport();
                }
                else
                {
                    MessageBox.Show("ERROR: Import already runnung");
                    return;
                }
                _import.SchemaOnly = schemaOnly;
                FeatureClassImportProgressReporter reporter = await FeatureClassImportProgressReporter.Create(_import, ((FeatureClassListViewItem)datasetObject).FeatureClass);

                FormTaskProgress progress = new FormTaskProgress();
                progress.Text = "Import Featureclass: " + ((FeatureClassListViewItem)datasetObject).Text;
                progress.ShowProgressDialog(reporter, ImportAsync(datasetObject));
                _import = null;
            }
        }
        async static public Task <FeatureClassImportProgressReporter> Create(FDBImport import, IFeatureClass source)
        {
            var reporter = new FeatureClassImportProgressReporter();

            if (import == null)
            {
                return(reporter);
            }
            reporter._cancelTracker = import.CancelTracker;

            if (source != null)
            {
                reporter._report.featureMax = await source.CountFeatures();
            }
            import.ReportAction   += new FDBImport.ReportActionEvent(reporter.import_ReportAction);
            import.ReportProgress += new FDBImport.ReportProgressEvent(reporter.import_ReportProgress);
            import.ReportRequest  += new FDBImport.ReportRequestEvent(reporter.import_ReportRequest);

            return(reporter);
        }