//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
+// Ankit Jain <JAnkit@novell.com>
//
// (C)2005 Novell Inc,
+// (C)2006 Novell Inc,
//
-#if NET_2_0
using System.Runtime.Serialization;
using System.Threading;
{
[Serializable]
public sealed class CommittableTransaction : Transaction,
- ISerializable, IDisposable, IAsyncResult
+ ISerializable, IDisposable, System.IAsyncResult
{
-
TransactionOptions options;
+
AsyncCallback callback;
object user_defined_state;
- bool committing;
- bool completed;
+
+ IAsyncResult asyncResult;
public CommittableTransaction ()
: this (new TransactionOptions ())
this.options = options;
}
- [MonoTODO]
- public IAsyncResult BeginCommit (AsyncCallback callback,
- object user_defined_state)
+ public IAsyncResult BeginCommit (AsyncCallback asyncCallback,
+ object asyncState)
{
- if (committing)
- throw new InvalidOperationException ();
- this.committing = true;
- this.callback = callback;
- this.user_defined_state = user_defined_state;
- // FIXME: invoke another thread and set WaitHandle.
+ this.callback = asyncCallback;
+ this.user_defined_state = asyncState;
+
+ AsyncCallback cb = null;
+ if (asyncCallback != null)
+ cb = new AsyncCallback (CommitCallback);
+
+ asyncResult = BeginCommitInternal (cb);
return this;
}
-
- public void Commit ()
+
+ public void EndCommit (IAsyncResult asyncResult)
{
- EndCommit (BeginCommit (null, null));
+ if (asyncResult != this)
+ throw new ArgumentException ("The IAsyncResult parameter must be the same parameter as returned by BeginCommit.", "asyncResult");
+
+ EndCommitInternal (this.asyncResult);
}
- [MonoTODO]
- public void EndCommit (IAsyncResult asyncResult)
+ private void CommitCallback (IAsyncResult ar)
{
- if (asyncResult != this)
- throw new InvalidOperationException ();
- throw new NotImplementedException ();
+ if (asyncResult == null && ar.CompletedSynchronously)
+ asyncResult = ar;
+ callback (this);
}
- [MonoTODO]
+ public void Commit ()
+ {
+ CommitInternal ();
+ }
+
+ [MonoTODO ("Not implemented")]
void ISerializable.GetObjectData (SerializationInfo info,
StreamingContext context)
{
get { return user_defined_state; }
}
- [MonoTODO]
WaitHandle IAsyncResult.AsyncWaitHandle {
- get { throw new NotImplementedException (); }
+ get { return asyncResult.AsyncWaitHandle; }
}
- [MonoTODO]
bool IAsyncResult.CompletedSynchronously {
- get { throw new NotImplementedException (); }
+ get { return asyncResult.CompletedSynchronously; }
}
bool IAsyncResult.IsCompleted {
- get { return completed; }
+ get { return asyncResult.IsCompleted; }
}
+
+
}
}
-#endif