示例#1
0
        /// <summary>
        /// Start tracking a resource
        /// </summary>
        /// <param name="resourceName"></param>
        /// <param name="runOnItsOwn"></param>
        /// <returns>If the resource is blocked</returns>
        public static bool ResourceIsBlocked(string resourceName, bool runOnItsOwn)
        {
            lock (SingletonKey)
            {
                var resource = new Resource(
                    id: resourceName,
                    runOnItsOwn: runOnItsOwn);

                // Index
                Slots.Add(resource);

                var blocked = Slots.Blocked(resource);

                Log(">", resource);

                return(blocked);
            }
        }
示例#2
0
        /// <summary>
        /// Check if the resource is still blocked
        /// </summary>
        /// <param name="resourceName"></param>
        /// <returns></returns>
        public static bool ResourceIsBlocked(string resourceName)
        {
            lock (SingletonKey)
            {
                var resource = Slots.GetResource(resourceName);
                if (resource == null)
                {
                    throw new IndexOutOfRangeException($"A resource named {resourceName} has not been setup with a runOnItsOwn context");
                }

                var blocked = Slots.Blocked(resource);
                if (!blocked)
                {
                    Log("*", resource);
                }
                else
                {
                    // Log("?", test); // Only for debugging to prove that block checks are ongoing
                }
                return(blocked);
            }
        }