Example #1
0
        public void AddEmployee_ShouldMatchEmployeeEnries_UsingMultiThreading()
        {
            EmployeeRepo repo = new EmployeeRepo();

            EmployeePayroll employee = new EmployeePayroll();

            employee.EmployeeName = "ktrrr";
            employee.Department   = ".Net";
            employee.StartDate    = DateTime.Parse("10-24-2009");

            DateTime startTime = DateTime.Now;

            repo.AddEmployee(employee);
            repo.AddEmployee(employee);
            repo.AddEmployee(employee);
            DateTime stopTime = DateTime.Now;

            Console.WriteLine("Duration without thread: " + (stopTime - startTime));

            DateTime startTime2 = DateTime.Now;

            repo.AddEmployeeWithThread(employee);
            repo.AddEmployeeWithThread(employee);
            repo.AddEmployeeWithThread(employee);
            DateTime stopTime2 = DateTime.Now;

            Console.WriteLine("Duration with thread: " + (stopTime2 - startTime2));
        }