MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




Load new map in separate thread to keep ui responsive?

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. ...


Go Back   MapPoint Forums > Map Forums > MapPoint 2006/2009 Discussion

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read



Click here to register

Reply

 

LinkBack (1) Thread Tools Display Modes
  1 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 11-09-2005
Junior Member
White Belt
 
Join Date: Nov 2005
Posts: 4
Load new map in separate thread to keep ui responsive?

Anyone know how I can accomplish this? I don't like how my program freezes when I'm loading a new map. Here's my attempt, can anyone tell me what I'm missing or what I should be reading up on?

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 11-09-2005
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,122
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...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 11-09-2005
Junior Member
White Belt
 
Join Date: Nov 2005
Posts: 4
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
my second attempt has a little better results ...it at least gives it a chance to repaint my main window before the axcontrol.newmap() is called...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4 (permalink)  
Old 11-11-2005
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,122
Hi,

Quote:
Is it just me or does loading a new map take forever?
Can take up to a few seconds, depending on the speed of the machine even a douzan of seconds

Quote:
So you're saying it's not possible to thread the loading of the control
No I did not say that. Euh maybe I did, but it was not meanth so (English is not my native language, so...). What I was trying to say is that it quite well possible that this works, but you will pretty sure go into troubles later because you are for sure doing an untested situation, and it is for sure not by design to be used as such.

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
load, map, responsive, separate, thread


LinkBacks (?)
LinkBack to this Thread: http://www.mapforums.com/load-new-map-separate-thread-keep-ui-responsive-4605.html

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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

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


All times are GMT -5. The time now is 11:06 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
MP2K Magazine
Visitor Map


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55