public async Task CreateImageAsync(ImageModel img, IFormFileCollection files) { Bitmap grey50, grey80, grey100, convolutionTasks; Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); // generate new file name string fileName = Guid.NewGuid().ToString(); int tiles = img.GetCorrectTilesForProcessing(); img.AmountOfThreads = tiles; img.Title = fileName; img.SourceOriginal = await _fileManager.SaveImageAsync(files, ProjectConstants.OriginalImageBasePath, ProjectConstants.OriginalImageResultPath, fileName); string fullPath = _fileManager.ImageFullPath(img.SourceOriginal); Bitmap imageSource = (Bitmap)Image.FromFile(fullPath); if (tiles == 1) { SobelAlgorithm imageProcessAlg = new SobelAlgorithm(); grey50 = imageProcessAlg.SobelFilter(imageSource, 50); grey80 = imageProcessAlg.SobelFilter(imageSource, 80); grey100 = imageProcessAlg.SobelFilter(imageSource, 100); convolutionTasks = imageProcessAlg.ConvolutionFilter(imageSource); } else { //grey50 = ConvertImageWithShedulerTasks(imageSource, tiles, 1, 50); //grey80 = ConvertImageWithShedulerTasks(imageSource, tiles, 1, 80); //grey100 = ConvertImageWithShedulerTasks(imageSource, tiles, 1, 100); //convolutionTasks = ConvertImageWithShedulerTasks(imageSource, tiles, 2, 0); grey50 = ConvertImageWithTasks(imageSource, tiles, 1, 50); grey80 = ConvertImageWithTasks(imageSource, tiles, 1, 80); grey100 = ConvertImageWithTasks(imageSource, tiles, 1, 100); convolutionTasks = ConvertImageWithTasks(imageSource, tiles, 2, 0); } img.SourceGrey50 = _fileManager.SaveBitMapToImage(grey50, ProjectConstants.TransformImageResultPath, fileName + "_grey50"); img.SourceGrey80 = _fileManager.SaveBitMapToImage(grey80, ProjectConstants.TransformImageResultPath, fileName + "_grey80"); img.SourceGrey100 = _fileManager.SaveBitMapToImage(grey100, ProjectConstants.TransformImageResultPath, fileName + "_grey100"); img.SourcConvolutionTasks = _fileManager.SaveBitMapToImage(convolutionTasks, ProjectConstants.TransformImageResultPath, fileName + "_convTasks"); await _imageAlgorithm.CreateImageAsync(img); await _imageAlgorithm.SaveChangesAsync(); stopwatch.Stop(); var asd = stopwatch.Elapsed; }