Beispiel #1
0
    static void Main(string[] args)
    {
        try
        {
            // Create a container to hold employees
            Employees employees = new Employees(4);

            // Create and drain our simulated message queue
            EmployeeQueueMonitor monitor =
                new EmployeeQueueMonitor(employees);

            monitor.start();
            monitor.stop();

            // Display the employee list on screen
            Console.WriteLine(
                "List of employees added via delegate:");

            foreach (Employee employee in employees)
            {
                string name = employee.FirstName + " " +
                              employee.MiddleName + " " + employee.LastName;

                string ssn = employee.SSN;

                Console.WriteLine("Name: {0}, SSN: {1}", name, ssn);
            }
        }
        catch (Exception exception)
        {
            // Display any errors on screen
            Console.WriteLine(exception.Message);
        }
    }
    static void Main(string[] args)
    {
        try
        {
            // Create a container to hold employees
            Employees employees = new Employees();

            // Create and drain our simulated message queue
            EmployeeQueueMonitor monitor =
                new EmployeeQueueMonitor(employees);

            monitor.start();
            monitor.stop();

            // Display employees that were added and their payroll
            Console.WriteLine("List of employees added via event:");
            foreach (Employee employee in employees)
            {
                string name = employee.FirstName + " " +
                              employee.MiddleName + " " + employee.LastName;

                string ssn     = employee.SSN;
                string empType = employee.GetType().ToString();

                Console.WriteLine(
                    "Name: {0}, SSN: {1}, Pay Type: {2}, Pay: {3}",
                    name, ssn, empType, employee.Payroll.ToString());
            }
        }
        catch (Exception exception)
        {
            // Write exceptions to screen
            Console.WriteLine(exception.Message);
        }
    }