public void Dispose()
        {
            using (Lock.Enter())
            {
                StopWatch?.Stop();
                PerfCounter?.Dispose();
                Queue?.Clear();
                Unique?.Clear();

                StopWatch   = null;
                PerfCounter = null;
                Queue       = null;
                Unique      = null;
            }
        }
 public bool?TryClear()
 {
     using (EntryBlockUC entry = Lock.TryEnter())
     {
         if (entry.EntryTypeUC == EntryTypeUC.None)
         {
             return(null);
         }
         if (Queue == null)
         {
             return(false);                               //disposed
         }
         if (StopWatch?.IsRunning == true)
         {
             return(false);
         }
         Queue.Clear();
         Unique.Clear();
         ReadCounter = 0;
         return(true);
     }
 }
예제 #3
0
    static bool OnSmallCaveTwice(Cave cave, IEnumerable <Cave> path)
    {
        if (!cave.IsSmall)
        {
            return(false);
        }
        Unique.Clear();
        var caveTwice        = false;
        var containsAddition = false;

        foreach (var prev in path.Skip(1).Where(t => t.IsSmall))
        {
            if (prev == cave)
            {
                if (caveTwice || containsAddition)
                {
                    return(true);
                }
                else
                {
                    containsAddition = true;
                }
            }
            else if (!Unique.Add(prev))
            {
                if (caveTwice || containsAddition)
                {
                    return(true);
                }
                else
                {
                    caveTwice = true;
                }
            }
        }
        return(false);
    }