1 //
2 // PreparingEnlistment.cs
3 //
4 // Author:
5 //	Atsushi Enomoto  <atsushi@ximian.com>
6 //	Ankit Jain	 <JAnkit@novell.com>
7 //
8 // (C)2005 Novell Inc,
9 // (C)2006 Novell Inc,
10 //
11 
12 
13 using System.Threading;
14 
15 namespace System.Transactions
16 {
17 	public class PreparingEnlistment : Enlistment
18 	{
19 		bool prepared = false;
20 		Transaction tx;
21 		IEnlistmentNotification enlisted;
22 		WaitHandle waitHandle;
23 		Exception ex;
24 
PreparingEnlistment(Transaction tx, IEnlistmentNotification enlisted)25 		internal PreparingEnlistment (Transaction tx, IEnlistmentNotification enlisted)
26 		{
27 			this.tx = tx;
28 			this.enlisted = enlisted;
29 			waitHandle = new ManualResetEvent (false);
30 		}
31 
ForceRollback()32 		public void ForceRollback ()
33 		{
34 			ForceRollback (null);
35 		}
36 
InternalOnDone()37 		internal override void InternalOnDone ()
38 		{
39 			this.Prepared();
40 		}
41 
42 		[MonoTODO]
ForceRollback(Exception e)43 		public void ForceRollback (Exception e)
44 		{
45 			tx.Rollback (e, enlisted);
46 			/* See test RMFail2 */
47 			((ManualResetEvent) waitHandle).Set ();
48 		}
49 
50 		[MonoTODO]
Prepared()51 		public void Prepared ()
52 		{
53 			prepared = true;
54 			/* See test RMFail2 */
55 			((ManualResetEvent) waitHandle).Set ();
56 		}
57 
58 		[MonoTODO]
RecoveryInformation()59 		public byte [] RecoveryInformation ()
60 		{
61 			throw new NotImplementedException ();
62 		}
63 
64 		internal bool IsPrepared {
65 			get { return prepared; }
66 		}
67 
68 		internal WaitHandle WaitHandle {
69 			get { return waitHandle; }
70 		}
71 
72 		internal IEnlistmentNotification EnlistmentNotification
73 		{
74 			get { return enlisted; }
75 		}
76 
77 		// Uncatched exceptions thrown during prepare will
78 		// be saved here so they can be retrieved by TM.
79 		internal Exception Exception
80 		{
81 			get { return ex; }
82 			set { ex = value; }
83 		}
84 	}
85 }
86 
87