BF2Statistics.GamespyRedirectForm.GetRedirectAddressesAsync C# (CSharp) Method

GetRedirectAddressesAsync() private method

Fetches the IP addresses of the hostnames provided in the redirect address boxes, and returns whether the provided hostnames were valid
private GetRedirectAddressesAsync ( ) : Task
return Task
        private Task<bool> GetRedirectAddressesAsync()
        {
            // Get our user input
            string Bf2Web = Bf2webAddress.Text.Trim().ToLower();
            string Gamespy = GamespyAddress.Text.Trim().ToLower();

            // Reset values
            StatsServerAddress = null;
            GamespyServerAddress = null;

            // Return this processing task to be awaited on
            return Task.Run<bool>(() =>
            {
                // Stats Server
                if (Bf2webCheckbox.Checked && Bf2Web != "localhost")
                {
                    // Need at least 8 characters
                    if (Bf2Web.Length < 8)
                    {
                        MessageBox.Show(
                            "You must enter an valid IP address or Hostname in the Address box!",
                            "Invalid Address", MessageBoxButtons.OK, MessageBoxIcon.Warning
                        );
                        return false;
                    }

                    // Reslove hostname if we were not provided an IP address
                    if (!Networking.TryGetIpAddress(Bf2Web, out StatsServerAddress))
                    {
                        MessageBox.Show(
                            "Stats server redirect address is invalid, or doesnt exist. Please enter a valid, and existing IPv4/6 or Hostname.",
                            "Invalid Address", MessageBoxButtons.OK, MessageBoxIcon.Warning
                        );

                        return false;
                    }
                }

                // Gamespy Server
                if (GpcmCheckbox.Checked && Gamespy != "localhost")
                {
                    // Need at least 8 characters
                    if (Gamespy.Length < 8)
                    {
                        MessageBox.Show(
                            "You must enter an valid IP address or Hostname in the Address box!",
                            "Invalid Address", MessageBoxButtons.OK, MessageBoxIcon.Warning
                        );
                        return false;
                    }

                    // Reslove hostname if we were not provided an IP address
                    if (!Networking.TryGetIpAddress(Gamespy, out GamespyServerAddress))
                    {
                        MessageBox.Show(
                            "Gamespy redirect address is invalid, or doesnt exist. Please enter a valid, and existing IPv4/6 or Hostname.",
                            "Invalid Address", MessageBoxButtons.OK, MessageBoxIcon.Warning
                        );

                        return false;
                    }
                }

                return true;
            });
        }