Esempio n. 1
0
        public async ValueTask Handle(IBackgroundTaskContext context)
        {
            if (context.BackgroundTask is not ImageFileInfoBackgroundTask infoBackgroundTask)
            {
                return;
            }

            var commandHelper = new CommandHelper();
            var logger        = loggerFactory.CreateLogger <InfoCommand>();
            var infoCommand   = new InfoCommand(logger, commandHelper, Enumerable.Empty <IPhysicalDrive>(),
                                                infoBackgroundTask.Path);

            infoCommand.DiskInfoRead += async(_, args) =>
            {
                await resultHubContext.SendInfoResult(args.MediaInfo.ToViewModel());
            };

            var result = await infoCommand.Execute(context.Token);

            if (result.IsFaulted)
            {
                await errorHubContext.SendError(result.Error.Message, context.Token);
            }
        }