Re: [Proposal] using statement enhancements

From: Helge Jensen (helge.jensen_at_slog.dk)
Date: 03/05/05


Date: Sat, 05 Mar 2005 14:33:53 +0100
To: cody <deutronium@gmx.de>


> The second idea I have is that we need some support for transactions in
> code. Currently we have to write huge statements like that to enable safe
> transaction handling:

The usual idiom is something like:

Transaction t = Transcations.Begin(...);
bool committed = false;
try {
   while ( still_not_done() )
     t.Operate(...);
   committed = t.Commit();
} finally {
   if ( !committed )
     t.Rollback();
}

Which nicely lets exception go to the caller of something goes wrong,
and completes cleanly otherwise.

-- 
Helge