/// <summary> /// Call the coordinator to proceed with transaction commit /// </summary> /// <returns></returns> public static bool TxCommit() { bool isCommited = false; if (TransactionId > 0) { int[] uidArray = padIntUids.ToArray(); if (HasAnyServerFreezed(uidArray)) { AsyncOperation commit = new AsyncOperation(coordinator.Commit); AsyncCallback commitCallback = new AsyncCallback(AsyncCommitCallBack); IAsyncResult RemAr = commit.BeginInvoke(TransactionId, uidArray, commitCallback, null); Console.WriteLine("Commit delays due to the freezed server."); } else { isCommited = coordinator.Commit(TransactionId, uidArray); Console.WriteLine("Transaction commit status is " + isCommited); } } else { Console.WriteLine("Server stabilization in progress"); } return(isCommited); }
/// <summary> /// Call coordinator to abort the transaction /// </summary> /// <returns></returns> public static bool TxAbort() { //TODO: abort the transaction. Call coordinator's abort method. The implementation is similar to commit. bool isAborted = false; try { if (TransactionId > 0) { if (padIntUids.Count() > 0) { int[] uidArray = padIntUids.ToArray(); if (HasAnyServerFreezed(uidArray)) { AsyncOperation abort = new AsyncOperation(coordinator.AbortTxn); AsyncCallback abortCallback = new AsyncCallback(AsyncAbortCallBack); IAsyncResult RemAr = abort.BeginInvoke(TransactionId, uidArray, abortCallback, null); Console.WriteLine("Abort delays due to the freezed server."); } else { isAborted = coordinator.AbortTxn(TransactionId, uidArray); } } else { Console.WriteLine("No UID has been manipulated to abort."); } } else { Console.WriteLine("Server stabilization in progress"); } } catch (Exception ex) { Common.Logger().LogError(ex.Message, ex.StackTrace, ex.Source); Console.WriteLine("Default abort is not executed."); } return(isAborted); }
/// <summary> /// Runs the method asynchronously. Return immediately. /// </summary> /// <param name="parameters">parameters for the method (delegate) </param> public void RunAsync(object[] parameters) { AsyncCallback callBack = new AsyncCallback(MyAsyncCallback); m_asyncoperation_internal.BeginInvoke(parameters, null, null); }