Esempio n. 1
0
        private async void buttonGetStudentsAsyncAwaitDelay_Click(object sender, EventArgs e)
        {
            ClearLogAndDataGridView();

            List <Student>     students   = new List <Student>();
            IStudentDataAccess dataAccess = new StudentSQLDataAccess();

            UpdateLog("Starting: GetStudents Async/Await Delay");
            students = await dataAccess.GetStudentsAsync();

            UpdateLog("Delaying: Delaying for 5 seconds...");
            await Task.Delay(1000);

            UpdateLog("Delaying: Delaying for 4 seconds...");
            await Task.Delay(1000);

            UpdateLog("Delaying: Delaying for 3 seconds...");
            await Task.Delay(1000);

            UpdateLog("Delaying: Delaying for 2 seconds...");
            await Task.Delay(1000);

            UpdateLog("Delaying: Delaying for 1 second...");
            await Task.Delay(1000);

            UpdateLog("Finished: GetStudents Async/Await Delay");

            UpdateLog("Starting: Binding to DataGridView");
            dataGridViewStudents.DataSource = students;
            UpdateLog("Finished: Binding to DataGridView");
        }
Esempio n. 2
0
        private async void buttonGetStudents_Click(object sender, EventArgs e)
        {
            ClearLogAndDataGridView();

            List <Student>     students   = new List <Student>();
            IStudentDataAccess dataAccess = new StudentSQLDataAccess();

            UpdateLog("Starting: GetStudents Async/Await");
            students = await dataAccess.GetStudentsAsync();

            UpdateLog("Finished: GetStudents Async/Await");

            UpdateLog("Starting: Binding to DataGridView");
            dataGridViewStudents.DataSource = students;
            UpdateLog("Finished: Binding to DataGridView");
        }
Esempio n. 3
0
        private void buttonBreakApp_Click(object sender, EventArgs e)
        {
            ClearLogAndDataGridView();

            List <Student>     students   = new List <Student>();
            IStudentDataAccess dataAccess = new StudentSQLDataAccess();

            UpdateLog("Starting: GetStudents Result");
            UpdateLog("Broken: It broke... Oh oh....");
            students = dataAccess.GetStudentsAsync().Result;
            UpdateLog("Finished: How though?!");

            UpdateLog("Starting: Binding to DataGridView");
            dataGridViewStudents.DataSource = students;
            UpdateLog("Finished: Binding to DataGridView");
        }
Esempio n. 4
0
        private void BtnGetStudentsAsyncAwait2_Click(object sender, EventArgs e)
        {
            ClearLogAndDataGridView();

            List <Student>     students   = new List <Student>();
            IStudentDataAccess dataAccess = new StudentSQLDataAccess();

            UpdateLog("Starting: GetStudents Async/Await 2");
            Task.Factory.StartNew(async() =>
            {
                students = await dataAccess.GetStudentsAsync();
                WriteTextSafe("Finished: GetStudents Async/Await 2");

                WriteTextSafe("Starting: Binding to DataGridView");
                UpdateDataGridViewSafe(students);
                WriteTextSafe("Finished: Binding to DataGridView");
            });
        }
Esempio n. 5
0
        private void ButtonGetStudentsNonResponsive_Click(object sender, EventArgs e)
        {
            ClearLogAndDataGridView();

            List <Student>     students   = new List <Student>();
            IStudentDataAccess dataAccess = new StudentSQLDataAccess();

            UpdateLog("Starting: GetStudents Non Responsive");
            UpdateLog("Delaying: Delaying for 5 seconds...");

            var task = Task.Factory.StartNew(async() => students = await dataAccess.GetStudentsAsync());

            task.Wait();

            Task.Delay(5000).Wait();
            UpdateLog("Finished: GetStudents Non Responsive");

            UpdateLog("Starting: Binding to DataGridView");
            dataGridViewStudents.DataSource = students;
            UpdateLog("Finished: Binding to DataGridView");
        }