Exemple #1
0
    static void Main(string[] args)
    {
        // create an instance from the derived type
        EventStack <int> eStack = new EventStack <int>();
        // upcast to the base generic class
        GenericStack <int> gSTack = eStack;

        // use a lambda expression to register with the event
        eStack.PoppedEvent += (sender, eventArg) => {
            Console.WriteLine("Popped Event Invoked");
        };

        // push some data into the stack
        eStack.Push(1);
        eStack.Push(2);
        eStack.Push(3);

        // pop the data back out of the stack
        for (int i = 0; i < 3; i++)
        {
            Console.WriteLine("Popped Value: {0}", eStack.Pop());
        }

        // wait for input before exiting
        Console.WriteLine("Press enter to finish");
        Console.ReadLine();
    }
 private void RemoveEvent()
 {
     if (!retryEventRemoved && retryEventAdded)
     {
         lock (lockEvents)
         {
             retryEventStack.Pop();
             retryEventRemoved = true;
         }
     }
 }
Exemple #3
0
    static void Main(string[] args)
    {
        // create an instance from the derived type
        EventStack <int> eStack = new EventStack <int>();

        // push some data into the stack
        eStack.Push(1);
        eStack.Push(2);
        eStack.Push(3);

        // pop the data back out of the stack
        for (int i = 0; i < 3; i++)
        {
            Console.WriteLine("Popped Value: {0}", eStack.Pop());
        }

        // wait for input before exiting
        Console.WriteLine("Press enter to finish");
        Console.ReadLine();
    }