Skip to Content
Programming WCF Services, 3rd Edition
book

Programming WCF Services, 3rd Edition

by Juval Lowy
August 2010
Intermediate to advanced
908 pages
26h 22m
English
O'Reilly Media, Inc.
Content preview from Programming WCF Services, 3rd Edition

Chapter 8. Concurrency Management

Incoming client calls are dispatched to the service on threads from the Windows I/O completion thread pool (the pool has 1,000 threads by default). Multiple clients can make multiple concurrent calls, and the service itself can sustain those calls on multiple threads. If the calls are dispatched to the same service instance, you must provide thread-safe access to the service’s in-memory state or risk state corruption and errors. The same is true for the client’s in-memory state during callbacks, since callbacks too are dispatched on threads from the I/O completion thread pool. In addition to synchronizing access to the instance state when applicable, all services also need to synchronize access to resources shared between instances, such as static variables. Another dimension altogether for concurrency management is ensuring that, if required, the service (or the resources it accesses) executes on particular threads.

WCF offers two modes for synchronization. Automatic synchronization instructs WCF to synchronize access to the service instance. Automatic synchronization is simple to use, but it is available only for service and callback classes. Manual synchronization, on the other hand, puts the full burden of synchronization on the developer and requires application-specific integration. The developer needs to employ .NET synchronization locks, which is by far an expert discipline. The advantages of manual synchronization are that it is available ...

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

Programming WCF Services, 4th Edition

Programming WCF Services, 4th Edition

Juval Lowy, Michael Montgomery
Programming .NET Security

Programming .NET Security

Adam Freeman, Allen Jones

Publisher Resources

ISBN: 9781449382476Supplemental ContentErrata Page