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

            PlotInfo plotInfo = new PlotInfo();

            myFirefly = new FireflyAlgorithm(numFireflies, maxEpochs, minX, maxX, values);
            FunctionDelegate functionDelegate = null;

            switch (ComboBox.SelectedIndex)
            {
            case 0:
                functionDelegate = Functions.Michalewicz;
                break;

            case 1:
                functionDelegate = Functions.Rosenbrock;
                break;

            case 2:
                functionDelegate = Functions.Ackley;
                break;

            case 3:
                functionDelegate = Functions.Rastrigin;
                break;

            case 4:
                functionDelegate = Functions.Sphere;
                break;

            case 5:
                functionDelegate = Functions.Levy;
                break;

            case 6:
                functionDelegate = Functions.Griewank;
                break;

            case 7:
                functionDelegate = Functions.Schwefel;
                break;

            default:
                break;
            }
            plotInfo = await CalculatePlotInfo(myFirefly, functionDelegate);

            ShowDetails(plotInfo.BestPostion, plotInfo.TrueMin, plotInfo.Val, plotInfo.Error);
            GeneratePlot(plotInfo);
        }
 public Task <PlotInfo> CalculatePlotInfo(FireflyAlgorithm myFirefly, FunctionDelegate functionDelegate)
 {
     return(Task.Factory.StartNew(() => myFirefly.Start(functionDelegate)));
 }