Just to answer my own question...

I tried this approach, and it seems to work.  My background thread waits for
DirectInput events to arrive, and posts a custom message (via PostMessage)
to a registered window whenever one arrives.  This moves all calls back into
the RB code to the main thread's message loop, making everything safe.

Thanks once again to James for the help with this - I'm on the home straight
now, I think :-)

Dave.

> From: Dave Addey <[EMAIL PROTECTED]>
> Reply-To: REALbasic Plugins <[email protected]>
> Date: Wed, 26 Apr 2006 17:30:23 +0100
> To: REALbasic Plugins <[email protected]>
> Conversation: Storing global data (was Callbacks and events on Windows)
> Subject: Re: Storing global data (was Callbacks and events on Windows)
> 
> Hi James,
> 
> Thanks!   Any help you can give is very much appreciated.
> 
> One thought I had: do I need to run a background thread to keep an eye out
> for these events?  The thread would then post custom user messages (WM_USER
> or above) to registered windows when an event occurs?  I think the process
> of posting an event to a window gets around the thread-calling-RB problems
> (a bit like Carbon Events on the Mac), but tbh I'm really not sure if I'm
> understanding it well enough to know if that's right or not :-)
> 
> Thanks in advance for the help!
> 
> Dave.
> 
>> Ah, sorry. I haven't read the DirectInput documentation yet; it's been years
>> since I've done any work with DirectInput.
>> 
>> Dredging up Win32 that I've done my best in the last couple of years to
>> suppress:
>> 
>> Events are objects that you create and use to send messages between threads.
>> You create an Event using CreateEvent and attach it to the DirectInput device
>> using SetEventNotification. You later query that Event using
>> MsgWaitForMultipleObjects to see if anything has happened for that device. If
>> anything has happened, you can then query the device. Typically you call
>> MsgWaitForMultipleObjects from another thread, as MsgWaitForMultipleObjects
>> can be told to block the thread until something happens.
>> 
>> I'll have a better read when I get home this evening. I'll be able to advise
>> you better then.
>> 
>> --
>> Kind regards,
>> James Milne
>> _______________________________________________
>> Unsubscribe or switch delivery mode:
>> <http://www.realsoftware.com/support/listmanager/>
>> 
>> Search the archives of this list here:
>> <http://support.realsoftware.com/listarchives/lists.html>
> 
> 
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
> 
> Search the archives of this list here:
> <http://support.realsoftware.com/listarchives/lists.html>


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to