473,385 Members | 1,593 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

WaitForSingleObject blocking

If I have some c++ class exported from a Win32 dll, and from some other
console application I created two threads and each thread creates an
instance of the exported class.

My question is related to using WaitForSingleObject from within the dll
class methods and if the two threads called a method in the dll that
blocks on WaitForSingleObject for a long time, then are the two
instances waiting for each other or if returned from
WaitForSingleObject it can continue event if the other thread still
blocked on its instance?

Thanks
Rami

Nov 17 '05 #1
5 2496
On 18 May 2005 07:44:42 -0700, ramialhasan wrote:
If I have some c++ class exported from a Win32 dll, and from some other
console application I created two threads and each thread creates an
instance of the exported class.

My question is related to using WaitForSingleObject from within the dll
class methods and if the two threads called a method in the dll that
blocks on WaitForSingleObject for a long time, then are the two
instances waiting for each other or if returned from
WaitForSingleObject it can continue event if the other thread still
blocked on its instance?


The threads wait on the object referred to by the HANDLE that you passed to
WFSO to become signaled or for the timeout interval you specified to
expire. Exactly what happens when the handle becomes signaled depends on
the type of the sync object. For example, only one thread is allowed to
acquire a mutex and progress, while the rest remain blocked (modulo
non-INFINITE timeout values) until that thread releases it (or terminates,
in which case it "abandons" the mutex), at which point, another thread can
acquire the mutex.

--
Doug Harrison
Microsoft MVP - Visual C++
Nov 17 '05 #2
Sorry but I mean that the two threads are calling the same method but
from different instances and each instance has its own copy of the sync
object. so they are not waiting on the same event but on different
evemts. But my question is related to DLL processing, so if one thread
is waiting on its own event is the other instances blocked two until
the waiting is released or each thread runs in its own processing
thread?
Regards,
Rami

Nov 17 '05 #3
ramialhasan wrote:
Sorry but I mean that the two threads are calling the same method but
from different instances and each instance has its own copy of the sync
object. so they are not waiting on the same event but on different
evemts. But my question is related to DLL processing, so if one thread
is waiting on its own event is the other instances blocked two until
the waiting is released or each thread runs in its own processing
thread?
Regards,
Rami


Each thread runs independently. If each thread is using a different
sync object they do not affect each other.

--
Scott McPhillips [VC++ MVP]

Nov 17 '05 #4
On 18 May 2005 13:34:22 -0700, ramialhasan wrote:
Sorry but I mean that the two threads are calling the same method but
from different instances and each instance has its own copy of the sync
object. so they are not waiting on the same event but on different
evemts. But my question is related to DLL processing, so if one thread
is waiting on its own event is the other instances blocked two until
the waiting is released or each thread runs in its own processing
thread?


I'm not sure what you think is special about DLLs. They're pretty much just
chunks of code and data loaded into your process's address space, though
the system does serialize the execution of DllMain functions. As for your
sync objects, if the HANDLEs you pass to WFSO refer to different sync
objects, no synchronization occurs between the two threads when they call
WFSO on their respective HANDLEs. They run independently of one another.

--
Doug Harrison
Microsoft MVP - Visual C++
Nov 17 '05 #5
Thanks for you all, now this is clear

Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: herbert | last post by:
Hi everybody; I've done 2 c++ class; server and client. I would like to make the same in c#. my waiting thread was waiting for 3 type of event: - a socket have data to read - a socket want...
4
by: izik l | last post by:
I have made the following main: void main() { HANDLE myMutex = CreateMutex( NULL, false, NULL ); WaitForSingleObject(myMutex, INFINITE); printf("should never appeared"); }
3
by: Mario | last post by:
Hello, I couldn't find a solution to the following problem (tried google and dejanews), maybe I'm using the wrong keywords? Is there a way to open a file (a linux fifo pipe actually) in...
4
by: Bill Sonia | last post by:
Hello, I have a Widnows Service that creates a system event that I would like to have a Sql Server stored procedure fire when the stored procedure is called. I have a Windows Service that runs...
6
by: Sean Kelly | last post by:
When both waiting on an event and a simple unnamed mutex, I'm wondering when WaitForSingleObject might return WAIT_FAILED. These are both execution paths I'd very much like to avoid exceptional...
1
by: Rachit | last post by:
Hi, I've a WebApp that calls Microsoft CRM WebServices to perform a particular action. In my WebApp I am spawning a new async thread for all the CRM related actions and sending the user to Thank...
1
by: stefan.sedich | last post by:
Hi I am trying to open an email in outlook with the following string command = "c:\\Program Files\\Microsoft Office\\OFFICE11\\OUTLOOK.EXE c:\\a.msg"; StartupInfo si = new StartupInfo();...
2
by: Sasie7679 | last post by:
In one of our windows XP pro with service pack2 machine, the below API's fail. 1) MsgWaitForMultipleObjectsEx 2) MsgWaitForMultipleObjects 3) WaitforSingleObject 4) WaitforSingleObjectEx In...
10
by: blisspikle | last post by:
I see a lot of examples posted for Waitforsingleobject API for Processes or threads, but not events. I cannot get waitforsingleobject to subscribe to an event. I use a class PLCEthernet which is...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.