Merge pull request #4453 from lambdageek/bug-49721
[mono.git] / mcs / class / System.Transactions / System.Transactions / PreparingEnlistment.cs
index 407a19325a17c519f39e4c0ba8bc0d87bd00d0fd..e662279f85b5c65a21e2728dd10d3b66e6855990 100644 (file)
@@ -9,7 +9,6 @@
 // (C)2006 Novell Inc,
 //
 
-#if NET_2_0
 
 using System.Threading;
 
@@ -20,13 +19,14 @@ namespace System.Transactions
                bool prepared = false;
                Transaction tx;
                IEnlistmentNotification enlisted;
-               //WaitHandle waitHandle;
+               WaitHandle waitHandle;
+               Exception ex;
 
                internal PreparingEnlistment (Transaction tx, IEnlistmentNotification enlisted)
                {
                        this.tx = tx;
                        this.enlisted = enlisted;
-                       //waitHandle = new ManualResetEvent (false);
+                       waitHandle = new ManualResetEvent (false);
                }
 
                public void ForceRollback ()
@@ -34,20 +34,25 @@ namespace System.Transactions
                        ForceRollback (null);
                }
 
+               internal override void InternalOnDone ()
+               {
+                       this.Prepared();                        
+               }
+
                [MonoTODO]
-               public void ForceRollback (Exception ex)
+               public void ForceRollback (Exception e)
                {
-                       tx.Rollback (ex, enlisted);
-                       /* See test RMFail2 
-                       ((ManualResetEvent) waitHandle).Set (); */
+                       tx.Rollback (e, enlisted);
+                       /* See test RMFail2 */
+                       ((ManualResetEvent) waitHandle).Set ();
                }
 
                [MonoTODO]
                public void Prepared ()
                {
                        prepared = true;
-                       /* See test RMFail2 
-                       ((ManualResetEvent) waitHandle).Set ();*/
+                       /* See test RMFail2 */
+                       ((ManualResetEvent) waitHandle).Set ();
                }
 
                [MonoTODO]
@@ -60,10 +65,22 @@ namespace System.Transactions
                        get { return prepared; }
                }
 
-               /*internal WaitHandle WaitHandle {
+               internal WaitHandle WaitHandle {
                        get { return waitHandle; }
-               }*/
+               }
+
+               internal IEnlistmentNotification EnlistmentNotification
+               {
+                       get { return enlisted; }
+               }
+
+               // Uncatched exceptions thrown during prepare will
+               // be saved here so they can be retrieved by TM.
+               internal Exception Exception
+               {
+                       get { return ex; }
+                       set { ex = value; }
+               }
        }
 }
 
-#endif