471,330 Members | 1,212 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,330 software developers and data experts.

RE: Can anyone suggest a better design approach?

You should never WaitForMultipleObjets or WaitForSingleObject on a GUI thread
(unless there's a very short timeout).

Creating another thread to perform the blocking (calling WaitFor...) is the
recommended approach.

Browse http://connect.microsoft.com/VisualStudio/feedback/ and vote.
Microsoft MVP, Visual Developer - Visual C#
"vi***@gmail.com" wrote:

I have a forms application which hosts an unmanaged dll. This dll
exposes some simple c style functions which I just call using pinvoke.
But all native functions call WaitForMultiple\singleObject and wait
for a particular event to come. The problem is, this event can fire
only when messages on the windows message queue gets processed. Hence
if I call these blocking functions from native DLL directly from .NET
code they just block the application forever.
The solution I thought is to start a new thread and make this thread
call the dll method. I shall also create an event and pass its handle
into the thread created, so that this newly created thread can wait
for this event to happen. But then I would end up creating thread each
time for every native dll API call(every native DLL APi call does a
waitforsingle\multiple objects). This is not good..
Can anybody suggest a better design approach?

Jun 27 '08 #1
0 860

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

17 posts views Thread by tshad | last post: by
31 posts views Thread by Jim Hubbard | last post: by
39 posts views Thread by windandwaves | last post: by
8 posts views Thread by rAinDeEr | last post: by
1 post views Thread by yang__lee | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.