MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




Can't GetActiveMap from a Thread

This is a discussion on Can't GetActiveMap from a Thread within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; Hi, I have an MFC app which has a mappoint ocx control. I call AfxBeginThread to update a bunch of ...


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 Thread Tools Display Modes
  #1 (permalink)  
Old 06-07-2005
Junior Member
White Belt
 
Join Date: May 2005
Posts: 9
Can't GetActiveMap from a Thread

Hi, I have an MFC app which has a mappoint ocx control. I call AfxBeginThread to update a bunch of pushpins from a database. The thread seems to be able to access the CMappointCtrl that the main thread uses, but the CMap returned by GetActiveMap() doesn't work right. When I do a QuickWatch in VS7 unter the CMap's __vptr "CXX0030: Error: expression cannot be evaluated"

Both threads do need to access the same CMappointCtrl and all it's parts, but not at the same time. While the AfxBeginThread() thread is running, the main thread doesn't need to touch it at all.

Thanks.
Stu
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 06-08-2005
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,112
Hi Stu,

I think that if the control is created in main thread that you have to access all also from the main thread. So you can do several things from out of your other threads.

- Send a message to the main thread The thread will block until the custom message handler is ready. Some of the mappoint things will generate a stupid syncrounious error.
- Do the same with PostMessage. This one is async. So thread will contnue.Mappoint will not complain.

In both of this, the custom message handler will execute in main thread context. If you dont know these are Win32 API calls and you can P/Invoke to run them in dotnet.

Possible you can do the same with Invoke / BeginInvoke (same for sync/async) if you create events in your threads. In that case you can let the events execute in main thread context.

Note that with all that synchronizing, you are actually disabling multithreading, so another question is do you really need threads ?
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
getactivemap, thread


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
Load new map in separate thread to keep ui responsive? TicK MapPoint 2006/2009 Discussion 3 11-11-2005 01:07 PM
Updating map in mapcontrol, through secondary thread malkotian MapPoint 2006/2009 Discussion 1 08-16-2005 03:44 PM
is Mappoint thread safe Wilfried MapPoint 2006/2009 Discussion 5 04-06-2005 02:50 PM


All times are GMT -5. The time now is 02:04 PM.


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