我尝试使用使用一些等待操作的方法编写一个类。这种情况使我将此方法定义为异步。但我不能从这个方法返回非空值。就我而言,BitmapImage。这是代码
public sealed class Thumbnailer
{
public async BitmapImage GetThumbImageFromFile(StorageFile sourceFile)
{
StorageItemThumbnail thumb = await sourceFile.GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode.PicturesView, 600, Windows.Storage.FileProperties.ThumbnailOptions.UseCurrentScale);
IRandomAccessStream thumbStream = thumb;
BitmapImage thumbPict = new BitmapImage();
thumbPict.SetSource(thumbStream);
return thumbPict;
}
}
如何解决这个问题?