views:

13

answers:

1

I have an application wherein I am hosting multiple types of content (images, PowerPoint presentations, videos etc) in a kiosk-type app. The user has to be able to page back and forth between these bits of content, preferably using gestures of the touchscreen on the kiosk, i.e. tap one side of the screen to go forward, the other side to go back.

Unfortunately, the controls that display the content could have further nesting, so I'm using a Win32 mouse hook to capture mouse clicks, checking if they are within a specified region. This works great. Unfortunately these click events are (indirectly) calling methods on the ActiveX control I'm using to host PP presentations (DSOFramer), and it's causing this nasty COM exception:

An outgoing call cannot be made since the application is dispatching an input-synchronous call. (Exception from HRESULT: 0x8001010D (RPC_E_CANTCALLOUT_ININPUTSYNCCALL))

My best guess is that the low level mouse hook is calling from a different thread, because if I make the call directly from the Winforms UI thread, there's no problem. I tried the standard Winforms Invoke/BeginInvoke with no success.

+1  A: 

I was using the typical Winforms cross-thread pattern:

if(InvokeRequired)
{
    Invoke(new Action(DoStuff));
}
else
{
    DoStuff();
}

Of course the control I'm calling from has no idea of the AX control, so I need to explicitly invoke the action. It also needs to use BeginInvoke, so the above becomes:

BeginInvoke(new Action(DoStuff));

Works now. Oops!

Matt Olenik