Counter.Increment C# (CSharp) Метод

Increment() публичный статический Метод

public static Increment ( ) : void
Результат void
    public static void Increment()
    {
        var count = Interlocked.Increment(ref counter);
        if (count > MaxCount)
        {
            throw new InvalidOperationException(
                $"The number of concurrent tests ({counter}) is greater than allowed ({MaxCount}).");
        }
    }

Usage Example

Пример #1
1
        private Trait ReadTrait(XmlReader reader, Counter<string> badTags)
        {
            string identifier = null;
            string description = null;
            string label = null;
            int oppositeOpinion = 0;
            int sameOpinion = 0;
            string[] opposites = new string[0];

            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element && reader.Name == "id")
                {
                    identifier = reader.ReadElementContentAsString();
                }
                else if (reader.NodeType == XmlNodeType.Element && reader.Name == "description")
                {
                    description = reader.ReadElementContentAsString();
                }
                else if (reader.NodeType == XmlNodeType.Element && reader.Name == "label")
                {
                    label = reader.ReadElementContentAsString();
                }
                else if (reader.NodeType == XmlNodeType.Element && reader.Name == "opposites")
                {
                    opposites = XmlHelper.ReadList(reader, "opposite", badTags);
                }
                else if (reader.NodeType == XmlNodeType.Element && reader.Name == "opposite_opinion")
                {
                    oppositeOpinion = reader.ReadElementContentAsInt();
                }
                else if (reader.NodeType == XmlNodeType.Element && reader.Name == "same_opinion")
                {
                    sameOpinion = reader.ReadElementContentAsInt();
                }
                else if (reader.NodeType == XmlNodeType.Element)
                {
                    badTags.Increment(reader.Name);
                }
                else if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "trait")
                {
                    break;
                }
            }
            return new Trait(identifier, label, description, sameOpinion, oppositeOpinion, opposites);
        }
All Usage Examples Of Counter::Increment