Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Results 1 to 2 of 2

Can't GetActiveMap from a Thread

This is a discussion on Can't GetActiveMap from a Thread within the MapPoint Desktop 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 ...

  1. #1
    discostu is offline 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

  2. #2
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    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 ?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Load new map in separate thread to keep ui responsive?
    By TicK in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 11-11-2005, 01:07 PM
  2. Updating map in mapcontrol, through secondary thread
    By malkotian in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 08-16-2005, 03:44 PM
  3. is Mappoint thread safe
    By Wilfried in forum MapPoint Desktop Discussion
    Replies: 5
    Last Post: 04-06-2005, 02:50 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127