public async override Task <OptimizerResult> Minimize(double[] parameters)
        {
            if (CancellationToken.IsCancellationRequested)
            {
                throw new TaskCanceledException();
            }

            if (_minimize == null)
            {
                var assembly = await _cSharpCompiler.CreateAssembly(Code);

                var worker = await _workerFactory.CreateAsync();

                _backgroundService = await worker.CreateBackgroundServiceAsync <MinimizeFacade>();

                _minimize = _cSharpCompiler.GetDelegate(assembly);
            }

            var cost = await _backgroundService.RunAsync(r => r.Minimize(_minimize, parameters)).Result;

            await Task.Run(() =>
            {
                ActivityLogger.Add(Guid.NewGuid().ToString(), Keys, parameters, cost);
                //ActivityLogger.Add("Parameters:", parameters);
                //ActivityLogger.Add("Cost:", cost);
                //ActivityLogger.StateHasChanged();
            });

            return(new OptimizerResult(parameters, cost));
        }
        public async Task <Dictionary <string, PlotlyData> > Split(string[] chunk)
        {
            if (_backgroundService == null)
            {
                var worker = await _workerFactory.CreateAsync();

                _backgroundService = await worker.CreateBackgroundServiceAsync <PlotlyLineSplitter>(new WorkerInitOptions
                {
                    DependentAssemblyFilenames = new[] { "Jtc.Optimization.Objects.dll", "Jtc.Optimization.Transformation.dll",
                                                         "System.Text.Json.dll" }
                });
            }

            return(await _backgroundService.RunAsync(s => s.Split(chunk)));
        }