MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




synchronous error

This is a discussion on synchronous error within the MapPoint 2006/2009 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 ...


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 04-05-2005
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,122
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 ?
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 04-05-2005
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,122
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
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 06-09-2005
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!
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 06-09-2005
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,122
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..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5 (permalink)  
Old 06-09-2005
Junior Member
White Belt
 
Join Date: Jun 2005
Posts: 2
Thank you very much Wilfried!
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
error, synchronous


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
Mappoint Error Mudrover MapPoint 2006/2009 Discussion 5 01-20-2005 03:59 PM
error 4014 SimonPearse MapPoint 2006/2009 Discussion 3 01-17-2005 11:47 AM
About ERROR 4-40028-1. Error or Bug ? Anonymous MapPoint 2006/2009 Discussion 12 01-11-2005 10:32 AM
I get this following error ananthdeena MapPoint 2006/2009 Discussion 3 01-01-2005 03:46 AM
Runtime Error 462 Anonymous MapPoint 2006/2009 Discussion 0 09-02-2004 05:07 AM


All times are GMT -5. The time now is 11:45 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 55