BF2Statistics.GamespyRedirectForm.AfterSelectProcessing C# (CSharp) Method

AfterSelectProcessing() protected method

When the Step is changed, this method handles the processing of the next step
protected AfterSelectProcessing ( ) : void
return void
        protected async void AfterSelectProcessing()
        {
            // Disable buttons until processing is complete
            NextBtn.Enabled = false;
            PrevBtn.Enabled = false;
            bool IsErrorFree;

            // Do processing
            // Get our previous step
            switch (pageControl1.SelectedTab.Name)
            {
                case "tabPageSelect":
                    // We dont do anything here
                    NextBtn.Enabled = true;
                    break;
                case "tabPageRedirectType":
                    // We dont do much here
                    PrevBtn.Enabled = NextBtn.Enabled = true;
                    break;
                case "tabPageVerifyHosts":
                case "tabPageVerifyIcs":
                    // Create new progress
                    SyncProgress<TaskStep> Myprogress = new SyncProgress<TaskStep>(RedirectStatusUpdate);

                    // Apply redirects
                    IsErrorFree = await Redirector.ApplyRedirectsAsync(Myprogress);
                    if (IsErrorFree)
                    {
                        NextBtn.Enabled = true;
                    }
                    else
                    {
                        // Remove redirect if there are errors
                        await Task.Delay(ERRORPAGE_DELAY);
                        ShowHostsErrorPage();
                    }
                    break;
                case "tabPageDiagnostic":
                    // Run in a new thread of course
                    bool DiagnosticResult = await Task.Run<bool>(() => VerifyDnsCache());

                    // Switch page
                    if (DiagnosticResult)
                    {
                        NextBtn.Enabled = true;
                    }
                    else
                    {
                        // Remove redirect if there are errors
                        Redirector.RemoveRedirects();
                        await Task.Delay(ERRORPAGE_DELAY);

                        // Show Error Page
                        ShowDnsErrorPage();
                    }
                    break;
                case "tabPageSuccess":
                    PrevBtn.Visible = false;
                    CancelBtn.Visible = false;
                    NextBtn.Text = "Finish";
                    NextBtn.Enabled = true;
                    NextBtn.Location = CancelBtn.Location;
                    return;
                case "tabPageError":
                    break;
            }

            // Unlock the previos button
            if (pageControl1.SelectedTab != tabPageSelect)
                PrevBtn.Enabled = true;
        }