public void GenerateTextureProfile() { if (this.transparencyColor == null || this.dialogViewModel != null) { return; } var textureProcessor = new TextureProcessor(); this.dialogViewModel = new DialogViewModel(); var pixelColors = this.sourceImage.CopyPixels(); TextureProfile textureProfile = null; this.dialogViewModel.AddTask ( async(taskContext) => { textureProfile = await textureProcessor.GenerateTextureProfileAsync(pixelColors, this.transparencyColor, this.dialogViewModel, taskContext); } ); this.windowManager.ShowDialog(this.dialogViewModel); this.dialogViewModel = null; this.Texture = new Texture(this.originalSource, textureProfile); this.DrawTextureOnOutput(); }