private async Task ConvertMultiAsync() { if (!IsMultiConversionEnabled()) { return; } if (_isProcessing != false) { _isProcessing = null; _scheduler?.Stop(); return; } using (new ProcessingScope(this)) { var count = 0; var nodes = _textures.Where(node => node.IsPicked).ToArray(); var settings = _settings.MultiConversion; await PublishUpdateStatusEventAsync(StatusType.Information, "TexturesConversionInitialization", nodes.Length); var collection = nodes.Select(node => new LambdaSchedulerTask(async() => { try { await _actionBuilder.Dispatch(CreateConvertTextureCommand(node.FileName, settings)) .CompleteFor <ActionSucceededNotification>() .CompleteFor <ErrorOccuredNotification>() .OnTimeout(async() => await PublishTimeoutEventAsync()) .Execute(); } finally { Interlocked.Increment(ref count); } await PublishUpdateStatusEventAsync(StatusType.Information, "TexturesConversionProgress", count, nodes.Length); })).ToArray(); _scheduler = new AsynchronousScheduler(Logger.Current, Environment.ProcessorCount); _scheduler.Subscribe(new SchedulerTaskCollection(collection)); await _scheduler.StartAsync(true); await PublishUpdateStatusEventAsync(StatusType.Ok, "TexturesConversionCompleted"); TexturePreview.Rebind(); } }
private async Task ConvertSingleAsync() { if (!IsSingleConversionEnabled() || (_isProcessing != false)) { return; } using (new ProcessingScope(this)) { await _actionBuilder.Dispatch(CreateConvertTextureCommand(TexturePreview.Name, _settings.SingleConversion)) .CompleteFor <ActionSucceededNotification>(async(context, @event) => await PublishUpdateStatusEventAsync(StatusType.Ok, "TextureConversionCompleted")) .CompleteFor <ErrorOccuredNotification>(async(context, @event) => await PublishUnknownErrorEventAsync()) .OnTimeout(async() => await PublishTimeoutEventAsync()) .Execute(); TexturePreview.Rebind(); } }
private async Task OnSingleChangedAsync() { TexturePreview.Rebind(); await OnChangedAsync(); }