Click here to Skip to main content
15,917,005 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i don't know how to use event in the threading concept..

i refer the msdn help.. but the program is very difficult to understand..

so can u help me. how to do that process...
Posted

1 solution

Looks like you want to know a lot about kernel objects :). Well, basically it's this way:

  1. You create an event, usually by calling CreateEvent function
  2. You pass handle of this event to all the threads that shall use your event. Depending on situation, there are numerous ways to do that - from passing handle in thread function arguments to duplicating it in another process
  3. When any of your threads need to wait for this event to occur, you call WaitForSingleObject or WaitForMultipleObjects function, passing event handle as an argument
  4. When condition being wait for is satisfied (you get the data to process, for example), another thread raises event by calling SetEvent function
  5. Next time waiting thread receives processor time, WaitForSingle object returns, so this thread can continue execution
  6. When needed, event can be reset (put in "not yet occured" state) by ResetEvent function, so you can repeat the process from step 3
  7. When no mere needed, Event handles should be closed by calling CloseHandle methods


This is very brief and incomplete description, missing a lot of details, but it should give you the basics. Something to start with before diving deeper into MSDN :)
 
Share this answer
 
Comments
@BangIndia 29-Jun-11 6:22am    
Great and thanks a lot!
Sergey Alexandrovich Kryukov 30-Jun-11 4:58am    
All correct, my 5.
--SA
Timberbird 30-Jun-11 5:11am    
Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900