Skip to Main Content
Programming WCF Services
book

Programming WCF Services

by Juval Lowy
February 2007
Intermediate to advanced content levelIntermediate to advanced
634 pages
16h 1m
English
O'Reilly Media, Inc.
Content preview from Programming WCF Services

Chapter 8. Concurrency Management

Incoming client calls are dispatched to the service on threads from the thread pool. Since multiple clients can make multiple concurrent calls, the service itself can sustain those calls on multiple threads. If those calls are dispatched to the same 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 thread pool. In addition to synchronizing access to the instance state when applicable, all services need to synchronize access to resources shared between instances, such as static variables or user-interface controls. 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 easy and simple to use, but it is only available for service and callback classes. Manual synchronization puts the full burden of synchronization on the developer, and requires application-specific integration. The developer needs to employ the .NET synchronization locks, and it is by far an expert discipline. The advantages of manual synchronization are that it is available for service and nonservice classes alike and it allows developers ...

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, 3rd Edition

Programming WCF Services, 3rd Edition

Juval Lowy
Mastering ASP.NET Web API

Mastering ASP.NET Web API

Mithun Pattankar, Malendra Hurbuns

Publisher Resources

ISBN: 0596526997Supplemental ContentErrata Page