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.
Synchronizing Multiple Processes with the Mutex
|
1045
Discussion
Semaphores are a new piece of the Framework in 2.0 and a welcome one. They are
primarily used for resource counting and are available cross-process when named (as
they are based on the underlying kernel semaphore object). Cross-process may not
sound too exciting to many .NET developers until they realize that cross-process also
means cross-AppDomain. If you are creating additional AppDomains to perform
work in, say, for instance, to hold assemblies you are loading dynamically that you
don’t want to stick around for the whole life of your main AppDomain, the sema-
phore can help you keep track of how many are loaded at a time. Being able to con-
trol access up to a certain number of users can be useful in many scenarios (socket
programming, custom thread pools, etc.).
See Also
See the “Semaphore,” “ManualResetEvent,” and “ParameterizedThreadStart” topics
in the MSDN documentation.
18.11 Synchronizing Multiple Processes with the Mutex
Problem
You have two processes or AppDomains that are running code with actions that you
need to coordinate.
Solution
Use a named Mutex as a common signaling mechanism to do the coordination. A
named
Mutex can be accessed from both pieces of code even when running in differ-
ent processes or AppDomains. ...
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