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

Callbacks and Synchronization Contexts

Like a service invocation, a callback may need to access resources that rely on some kind of thread(s) affinity. In addition, the callback instance itself may require thread affinity for its own use of the TLS, or for interacting with a UI thread. While the callback can use techniques such as those in Example 8-4 and Example 8-5 to marshal the interaction to the resource synchronization context, you can also have WCF associate the callback with a particular synchronization context by setting the UseSynchronizationContext property to true. However, unlike the service, the client does not use any host to expose the endpoint. If the UseSynchronizationContext property is true, the synchronization context to use is locked in when the proxy is opened (or, more commonly, when the client makes the first call to the service using the proxy, if Open() is not explicitly called). If the client is using the channel factory, the synchronization context to use is locked in when the client calls CreateChannel(). If the calling client thread has a synchronization context, this will be the synchronization context used by WCF for all callbacks to the client’s endpoint associated with that proxy. Note that only the first call made on the proxy (or the call to Open() or CreateChannel()) is given the opportunity to determine the synchronization context. Subsequent calls have no say in the matter. If the calling client thread has no synchronization context, even ...

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