Skip to Main Content
C# Cookbook, 2nd Edition
book

C# Cookbook, 2nd Edition

by Jay Hilyard, Stephen Teilhet
January 2006
Intermediate to advanced content levelIntermediate to advanced
1184 pages
43h 23m
English
O'Reilly Media, Inc.
Content preview from C# Cookbook, 2nd Edition
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Get the Naming Rights for Your Events
|
1059
Mel.CallWaitress( );
}
Discussion
There are two types of events, AutoResetEvent and ManualResetEvent. There are two
main differences between the events. The first is that
AutoResetEvents release only
one of the threads that are waiting on the event while a
ManualResetEvent will release
all of them when
Set is called. The second difference is that when Set is called on an
AutoResetEvent, it is automatically reset to a nonsignaled state while the ManualResetEvent
is left in a signaled state until the Reset method is called.
See Also
See the “AutoResetEvent” and “ManualResetEvent” topics in the MSDN documen-
tation and Programming Applications for Microsoft Windows, (Fourth Edition).
18.13 Get the Naming Rights for Your Events
Problem
You want to have code running in worker threads, or in other processes or AppDomains,
to be able to wait on an event.
Solution
Use the EventWaitHandle class, new to the 2.0 Framework. With it, you can create a
named event that will allow any code running on the local machine to find and wait
on the event.
AutoResetEvent and ManualResetEvent are excellent for signaling events
in threaded code and even between AppDomains if you are willing to go through the
hassle of passing the event reference around. Why bother? Both of
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C# Cookbook

C# Cookbook

Stephen Teilhet, Jay Hilyard
C# Cookbook

C# Cookbook

Joe Mayo
Head First C#, 4th Edition

Head First C#, 4th Edition

Andrew Stellman, Jennifer Greene

Publisher Resources

ISBN: 0596100639Supplemental ContentCatalog PageErrata