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 5 of 5

synchronous error

This is a discussion on synchronous error within the MapPoint Desktop Discussion forums, part of the Map Forums category; Hi, Anyone has seen this error, or can give me an explanation what it really means ? An outgoing call ...

  1. #1
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

    synchronous error

    Hi,

    Anyone has seen this error, or can give me an explanation what it really means ?

    An outgoing call cannot be made since the application is dispatching an input-synchronous call

    It happens in a mappoint create object model. I do nothing special, it is in a event from a serial port. Nothing blocking or synchronous.

    When I execute same code from eg a button click everytinng is fine. Any idea ? If I at least should understeand this phrase then I could debug better, if someone can explain it in simple english ?

  2. #2
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi Wilfried,

    You seems often talking to yourself

    I found the reason, however I dont know wy mappoint give this error. The serial port receive in a background thread and uses SendMessage win32 call to fire an DataAvailable event. Now there sits the problem. If I Post a message from that event to do the job the problem is gone.

    SendMessagei is of cource a synchronious call while PostMessage is asynchronious. But there shoul not be any problem, wy ahould mappoint complain, and also how can it detect it is called from within a SendMessage event ?

    any toughts ? I find it so stupid to post a message from within an event that is fired from a send message

  3. #3
    sisifo is offline Junior Member White Belt
    Join Date
    Jun 2005
    Posts
    2

    Any example please?

    Hi Wilfried,

    Thank you very much for your help.
    I read your second post and now I understand the reason for that problem, but, could you please give us an example of code in which you use Win32 API PostMessage to call mappoint functions or an url where we could find documentation about this?

    Thanks in advanced!

  4. #4
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi,

    Yes of course. Here it comes.

    This is the class you need to call Win32 API. I did part of it, but some more as the PostMessage, because these are often used routines:

    Code:
    using System.Runtime.InteropServices;   // needed to call external application (winAPI dll)
    
    namespace Mestdagh.biz
    {
        public static class Win32
        {
            [DllImport("kernel32.dll")]
            public static extern Boolean AllocConsole();
            [DllImport("User32.dll")]
            public static extern IntPtr FindWindow(string ClassName, string WindowName);
            [DllImport("User32.dll")]
            public static extern Boolean PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
            [DllImport("User32.dll")]
            public static extern Boolean PostMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);
            [DllImport("User32.dll")]
            public static extern Boolean SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
            [DllImport("User32.dll")]
            public static extern Boolean SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);
            [DllImport("User32.dll")]
            public static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);
        }
    To receive a message in a form you have to override the WndProc of the window. You do this as follow:

    Code:
            protected override void WndProc(ref Message m)
            {
                switch (m.Msg) {
                    case WM_UPDATEMP:
                        WMUpdateMP();
                        break;
                    default:
                        base.WndProc(ref m);
                        break;
                }
            }
    What about the WM_UPDATEMP ? You have to define it of course. Custom messages has to be larger that WM_USER, and WM_USER is 0x400, so:

    Code:
      const int WM_USER = 0x400;
      const int WM_UPDATEMP = WM_USER + 1;
    It is also very importand that you call the underlying WndProc for the messages you dont handle yourself, so dont forget to call the base.WndProc function in the default section. Also be sure that you cannot have an exception error in message handlers, so if you call external things (mappoint) be sure to have an exception block over there. To post a message you can do now exacly the same as in a normal Win32 program:

    Code:
        Win32.PostMessage(Handle, WM_UPDATEMP, 0, 0);
    What about parameters ? Whell you have the lParam and wParam as integer. You can give also a pointer to some object, or to other data. In most cases you have to go over to unsafe code of course (witch I find a very unlucky name because it has nothing to do with unsafe They had to call it 'unmanaged' or so to be more correct, but who am I to say that

    One last thing to say is that this is the way to go if you have threaded code and you have to call eg a mappoint function in main thread. A custom message handler is always executed in the trhead context of the destination window. In this example a form, so it is UI thread.

    I hope this answers the question..

  5. #5
    sisifo is offline Junior Member White Belt
    Join Date
    Jun 2005
    Posts
    2
    Thank you very much Wilfried!

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Mappoint Error
    By Mudrover in forum MapPoint Desktop Discussion
    Replies: 5
    Last Post: 01-20-2005, 03:59 PM
  2. error 4014
    By SimonPearse in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 01-17-2005, 11:47 AM
  3. About ERROR 4-40028-1. Error or Bug ?
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 12
    Last Post: 01-11-2005, 10:32 AM
  4. I get this following error
    By ananthdeena in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 01-01-2005, 03:46 AM
  5. Runtime Error 462
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 09-02-2004, 05:07 AM

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