/// <summary>
        /// The expression used to determine if a machine should should continue.
        /// Only continue if the machine is running and is not finished.
        /// </summary>
        protected static bool CheckMachineCanNotFinish(ActivityMachine machine)
        {
            if (machine == null)
            {
                return(false);
            }

            lock (machine._executionLock)
            {
                return(machine.CompletionCause == CompletionCause.Pending);
            }
        }
        /// <summary>
        /// The method used to determine if a machine should transition to final node.
        /// It indicates quitting if the machine's CompletionCause is other than 'Pending',
        /// or if it does not have a continue transition (meaning it is the last node);
        /// </summary>
        /// <param name="machine">the machine to check</param>
        /// <returns>True if the machine is finished or if the current node only has a quit transition.</returns>
        protected static bool CheckMachineCanFinish(ActivityMachine machine)
        {
            if (machine == null)
            {
                return(false);
            }

            lock (machine._executionLock)
            {
                if (machine.CompletionCause != CompletionCause.Pending)
                {
                    return(true);
                }

                var continueTransition = FindContinueTransition(machine.CurrentNode);
                // If somehow there is no continue transition, then the only way to finish is this nodes finish transition.
                return(continueTransition == null);
            }
        }