我有最新的MediatR(12.2.0),并且我有一个不返回任何内容的同步方法.我真的需要使用"异步任务"而不是"任务"吗?因为下面的方法给了我"并非所有代码路径都返回值":
public class UploadFileCommandHandler(IFileUploadingService fileUploadingService)
: IRequestHandler<UploadFileCommand>
{
private readonly IFileUploadingService _fileUploadingService = fileUploadingService;
public /* async */ Task Handle(UploadFileCommand request, CancellationToken cancellationToken)
{
_fileUploadingService.UploadFile(request.File); // <- this method returns VOID, not a task, see it below (the interface IFileUploadingService)
}
}
public interface IFileUploadingService
{
void UploadFile(File file);
}
我不得不添加"bloc",但我有警告"bloc方法缺乏等待".什么是正确的解决方案?