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();
            }
        }
示例#2
0
文件: Hub.cs 项目: S17L/iGP11
        public Hub(
            IEventRepository <HubEvent> hubEventRepository,
            IEventRepository <EndpointEvent> endpointEventRepository,
            IHubTransport hubTransport,
            ILogger logger)
        {
            _hubEventRepository      = hubEventRepository;
            _endpointEventRepository = endpointEventRepository;
            _hubTransport            = hubTransport;
            _logger = logger;

            _scheduler = new AsynchronousScheduler(_logger);
            _queue     = new EventQueue <HubEvent>(this, _hubEventRepository, new NoEventSchedulingPolicy(), _logger);
            _scheduler.Subscribe(_queue);
            _hubTransport.Connect(this);
            _scheduler.Start();
        }
示例#3
0
        public Endpoint(
            IHub hub,
            EndpointId id,
            IEventRepository <EndpointEvent> endpointEventRepository,
            IHubTransport hubTransport,
            ILogger logger,
            IAsynchronousScheduler scheduler)
        {
            _hub          = hub;
            _hubTransport = hubTransport;
            _scheduler    = scheduler;

            Id = id;

            _queue = new EventQueue <EndpointEvent>(this, endpointEventRepository, new NoEventSchedulingPolicy(), logger);
            _scheduler.Subscribe(_queue);
        }