loudcox
12-12-2007, 05:29 AM
Morning all
I've written an add-in that imports quite large datasets from text files using the Datasets.ShowImportWizard. However, it's not displaying the progress dialog that you get when using it through the interface.
My code is simply:
dsNew = TheMap.DataSets.ShowImportWizard(, strFilename, , 0)
Does anyone know why this is, and how I can fix it?
Many thanks
Mike
loudcox
12-13-2007, 08:59 AM
Managed to solve this, after a fashion. Since the import progress dialog is not displayed, I thought that I might display an animated form to show that something was happening, and then run the import on a thread.
This failed. However, a quick look at http://www.mapforums.com/multi-threading-add-6588.html#post17612 let me know that all calls to Mappoint must be on the originating thread.
So, I ended up with the following.
Public Class DoProgress
Private fb As frmBusy
Public Sub DisplayImportForm()
If fb Is Nothing Then fb = New frmBusy
fb.ShowDialog()
fb.Dispose()
End Sub
End ClassfrmBusy is just a borderless form with a PictureBox containing an animated GIF, and a timer to refresh the form every 500ms. Since we can't interrogate the creation of the new dataset, it appears there's no way to get progress, so this will suffice.
Then, when loading the data, the code is simply:
Dim cProgress As New DoProgress
Dim tProgress As New System.Threading.Thread(AddressOf cProgress.DisplayImportForm)
tProgress.Start()
dsNew = TheMap.DataSets.ImportData(strFilename, , MapPoint.GeoCountry.geoCountryUnitedKingdom, MapPoint.GeoDelimiter.geoDelimiterComma, 0)
tProgress.Abort()This means that when importing large datasets, the user doesn't think that Mappoint is hanging.
Wilfried
12-14-2007, 05:55 AM
Hi,
thanks for feedback. it sure helps others.