예제 #1
0
        internal void SetSplit(Split split)
        {
            if (this.tLock != null)
            {
                this.tLock.Dispose();
                this.tLock = null;
                this.split = null;
                this.otherSplit = null;
                this.transaction = null;
                this.originalTransaction = null;
            }

            if (split != null)
            {
                Debug.Assert(
                    split.Transaction.Splits.Count == 2 &&
                    split.Transaction.Splits.All(s => s.Security == split.Transaction.BaseSecurity),
                    "The transaction is too complex for the simple transaction editor.");

                this.originalTransaction = split.Transaction;
                this.transaction = split.Transaction.Copy();
                this.split = this.transaction.Splits[this.originalTransaction.Splits.IndexOf(split)];
                this.otherSplit = this.transaction.Splits.Where(s => s != this.split).Single();
                this.tLock = this.transaction.Lock();
            }

            ResetControls();
        }
예제 #2
0
 /// <summary>
 ///   Notifies the tracker of work beginning for a task
 /// </summary>
 /// <param name="taskName">Name of the task.</param>
 public static void work_begin(string taskName)
 {
     "TaskTracker".Log().Debug("Starting work for {0}".format_with(taskName));
     TransactionLock.enter(
         TASK_TRACKER_NAME,
         () =>
     {
         _activeTasksCount += 1;
         _activeTasks.Value.AddOrUpdate(taskName, 1, (key, oldValue) => oldValue + 1);
     });
 }
예제 #3
0
        /// <summary>
        ///   Determines if there are active tasks running.
        /// </summary>
        /// <returns>A boolean value</returns>
        public static bool are_active_tasks()
        {
            bool activeTasksRunning = true;

            TransactionLock.enter(TASK_TRACKER_NAME, 1, () => { if (_activeTasksCount == 0)
                                                                {
                                                                    activeTasksRunning = false;
                                                                }
                                  });

            return(activeTasksRunning);
        }
예제 #4
0
        /// <summary>
        ///   Gets the active tasks.
        /// </summary>
        /// <returns>The IEnumerable of active tasks.</returns>
        public static IEnumerable <string> get_active_tasks()
        {
            IList <string> activeTasks = new List <string>();

            TransactionLock.enter(
                TASK_TRACKER_NAME,
                () =>
            {
                foreach (var task in _activeTasks.Value)
                {
                    activeTasks.Add(task.Key);
                }
            });

            return(activeTasks);
        }
예제 #5
0
 /// <summary>
 ///   Notifies the tracker work has completed
 /// </summary>
 /// <param name="taskName">Name of the task.</param>
 public static void work_complete(string taskName)
 {
     "TaskTracker".Log().Debug("Completing work for {0}".format_with(taskName));
     TransactionLock.enter(
         TASK_TRACKER_NAME,
         () =>
     {
         _activeTasksCount -= 1;
         var taskCount      = 0;
         _activeTasks.Value.TryRemove(taskName, out taskCount);
         if (taskCount != 0)
         {
             taskCount -= 1;
             _activeTasks.Value.AddOrUpdate(taskName, taskCount, (key, oldValue) => taskCount);
         }
     });
 }