Exemple #1
0
        public bool Validate(SimpleTask task)
        {
            bool isValid             = false;
            bool isCheckerListLocked = true;

            do
            {
                if (Monitor.TryEnter(TheBestTaskNameCheckerInTheWorld.Names, 0))
                {
                    isCheckerListLocked = true;
                    try
                    {
                        lock (TheBestTaskNameCheckerInTheWorld.Names)
                        {
                            isValid = !TheBestTaskNameCheckerInTheWorld.Check(task.Name);
                            if (isValid)
                            {
                                TheBestTaskNameCheckerInTheWorld.Names.Add(task.Name);
                            }
                        }
                    }
                    finally
                    {
                        Monitor.Exit(TheBestTaskNameCheckerInTheWorld.Names);
                        isCheckerListLocked = false;
                    }
                }
            } while (isCheckerListLocked);

            return(isValid);
        }
        public void Patch(SimpleTask task)
        {
            if (task == null)
            {
                throw new ArgumentNullException("Task is null.");
            }

            Name               = task.Name;
            Status             = task.Status;
            LastUpdateDateTime = task.LastUpdateDateTime;
            LastUpdateBy       = task.LastUpdateBy;
            NumberOfUpdates    = task.NumberOfUpdates;
        }