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

Explicit Transaction Programming

The transactional programming model described so far can only be used declaratively by transactional services. Non-service clients, nontransactional services, and plain .NET objects called downstream by a service cannot take advantage of it. For all these cases, WCF relies on the transactional infrastructure available with .NET in the System.Transactions namespace. You may also rely on System.Transactions even in transactional services, when exploiting some advanced features such as transaction events, cloning, asynchronous commits, and manual transactions. I described the capabilities of System.Transactions in my MSDN whitepaper “Introducing System.Transactions in the .NET Framework 2.0” (published April 2005; updated December 2005). The following sections contain excerpts from that article describing how to use the core aspects of System.Transactions in the context of WCF. Please refer to the whitepaper for detailed discussions of the rest of the features.

The TransactionScope Class

The most common way of using transactions explicitly is via the TransactionScope class:

public sealed class TransactionScope : IDisposable
{
   public TransactionScope();
   //Additional constructors

   public void Complete();
   public void Dispose();
}

As its name implies, the TransactionScope class is used to scope a code section with a transaction, as demonstrated in Example 7-7.

Example 7-7. Using TransactionScope

using(TransactionScope scope = new TransactionScope()) { /* Perform ...
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