Beispiel #1
0
        /// <summary>
        /// Adds the specified id.
        /// </summary>
        /// <param name="id">The id.</param>
        public bool Add(string id, bool allowOnlySingleTask)
        {
            bool result = false;

            lock (syncRoot)
            {
                if (allowOnlySingleTask == true)
                {
                    string typeFullName = this.GetType().FullName;

                    if (SingleTaskIdByTypeName.Keys.Count(x => x == typeFullName) == 1)
                    {
                        result = false;
                    }
                    else
                    {
                        SingleTaskIdByTypeName.Add(typeFullName, id);

                        ProcessStatus.Add(id, 0);
                        ProcessStatusMessage.Add(id, "");

                        result = true;
                    }
                }
                else
                {
                    ProcessStatus.Add(id, 0);
                    ProcessStatusMessage.Add(id, "");

                    result = true;
                }
            }

            return(result);
        }
Beispiel #2
0
        /// <summary>
        /// Removes the specified id.
        /// </summary>
        /// <param name="id">The id.</param>
        public void Remove(string id)
        {
            lock (syncRoot)
            {
                ProcessStatus.Remove(id);
                ProcessStatusMessage.Remove(id);

                string typeFullName = this.GetType().FullName;
                if (SingleTaskIdByTypeName.Keys.Count(x => x == typeFullName) == 1)
                {
                    SingleTaskIdByTypeName.Remove(typeFullName);
                }
            }
        }