Community of VE/MapPoint Users and Developers
This is a discussion on Load new map in separate thread to keep ui responsive? within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; Anyone know how I can accomplish this? I don't like how my program freezes when I'm loading a new map. ...
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| Load new map in separate thread to keep ui responsive? Code:
Private Delegate Sub loadMapItem()
Private Sub Thread1Work()
Dim load As loadMapItem
Dim Result As IAsyncResult
load = New loadMapItem(AddressOf DelegateWork)
Result = AxMappointControl1.BeginInvoke(load)
Console.WriteLine("Thread 1 Done")
Console.WriteLine(Result.IsCompleted.ToString())
AxMappointControl1.EndInvoke(Result)
Console.WriteLine(Result.IsCompleted.ToString())
End Sub
Private Sub DelegateWork()
AxMappointControl1.Visible = False
AxMappointControl1.NewMap(1)
AxMappointControl1.Visible = True
Console.WriteLine("Delegate Done")
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Thread1 As Thread
Thread1 = New Thread(AddressOf Thread1Work)
Thread1.Start()
End Sub
|
| |||
|
Hi, You dont tell us what the problem is ! But you cannot use a visual component in a thread where it is not created in unless it is specially designed for that purpose using win32 CriticalSection. BTW, not only visual components, but the most of it...
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
|
Is it just me or does loading a new map take forever? (using axcontrol.newmap()). So you're saying it's not possible to thread the loading of the control so the program doesn't freeze up? Is it possible to speed this up somehow? Code: Private t As Thread
Private Sub Thread1Work()
AxMappointControl1.Visible = False
t.Sleep(1000)
AxMappointControl1.NewMap(1)
AxMappointControl1.Visible = True
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
t = New Thread(AddressOf Thread1Work)
t.Start()
End Sub
|
| |||
|
Hi, Quote:
Quote:
As general rule any component's methods should be called by the thread where it is created in, this includes the destroying of it. Unless the component is by design using CriticalSections to be called by several threads. For example there is no problem creating / using / destroying Mappoint object in a thread, but it can be a problem creating it in main thread and calling something from another thread.
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
![]() |
| Tags |
| load, map, responsive, separate, thread |
| ||||
| Posted By | For | Type | Date | |
| MapPoint 2009 Load Performance - Stack Overflow | This thread | Refback | 09-22-2008 02:08 PM | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Updating map in mapcontrol, through secondary thread | malkotian | MapPoint 2006/2009 Discussion | 1 | 08-16-2005 03:44 PM |
| Overlay two separate routes | jsfranks | MapPoint 2006/2009 Discussion | 1 | 07-20-2005 10:46 AM |
| Can't GetActiveMap from a Thread | discostu | MapPoint 2006/2009 Discussion | 1 | 06-08-2005 08:25 AM |
| is Mappoint thread safe | Wilfried | MapPoint 2006/2009 Discussion | 5 | 04-06-2005 02:50 PM |
| I have the following set of data in a tab-separate.... | Anonymous | MapPoint 2006/2009 Discussion | 1 | 12-26-2001 07:26 PM |