private async void CalculateButton_Click(object sender, RoutedEventArgs e)
        {
            if (!ValidateAll())
            {
                return;
            }

            PrevMessageText.Visibility = Visibility.Collapsed;
            ResultGrid.Visibility      = Visibility.Visible;

            ElapsedTimeTextBlock.Text = "--.--";
            LatitudeTextBlock.Text    = "--.--";
            LongitudeTextBlock.Text   = "--.--";

            ToggleCalculateButtonFunction();

            int    n      = int.Parse(PrecisionTextBox.Text);
            int    rounds = int.Parse(PopulationsTextBox.Text);
            int    size   = int.Parse(PopulationSizeTextBox.Text);
            double error  = double.Parse(ErrorTextBox.Text);
            bool   abs    = (bool)AbsErrRb.IsChecked;

            LogStackPanel.Children.Clear();

            var circles = new List <Circle>();

            AddLogToStackPanel("Usando los siguientes circulos:");
            foreach (RestrictionControl r in RestrictionsStackPanel.Children)
            {
                var circle = CoordinateCircleConverter.CoordinateToCircle(r.Coordinate);

                circles.Add(circle);
                AddLogToStackPanel($"x = {circle.X}, y = {circle.Y}, r = {circle.R}");
            }

            int timeout = int.Parse(TimerTextBox.Text);

            timer = new CancellationTokenSource();
            timer.CancelAfter(timeout);

            Stopwatch sw = new Stopwatch();

            sw.Start();

            SetProgressBar(timeout);

            try
            {
                var res = await Task.Run(() => Genetics.Calculate(circles.ToArray(), n, rounds, size, error, !abs, UpdateLogCrossThread, UpdateLogCrossThread, timer.Token), timer.Token);

                ResultsStackPanel.Visibility = Visibility.Visible;
                ErrorMessageGrid.Visibility  = Visibility.Collapsed;

                var result = CoordinateCircleConverter.CircleToCoordinate(new Circle
                {
                    X = res.Item2,
                    Y = res.Item3
                });

                LatitudeTextBlock.Text  = result.Latitude.ToString();
                LongitudeTextBlock.Text = result.Longitude.ToString();
            }
            catch (Exception ex)
            {
                ResultsStackPanel.Visibility = Visibility.Collapsed;
                ErrorMessageGrid.Visibility  = Visibility.Visible;

                if (ex is TimeoutException)
                {
                    ErrorMessageTextBlock.Text = "Se acabo el tiempo.";
                }
                else
                {
                    ErrorMessageTextBlock.Text = $"Ocurrió una excepción de tipo {ex.GetType().Name}\nMensaje: {ex.Message}";
                }
            }

            StopProgressBar();
            sw.Stop();
            ElapsedTimeTextBlock.Text = sw.Elapsed.ToString();

            ToggleCalculateButtonFunction();

            timer = null;
        }