为什么在第二种情况下抛出异常?
async void f() {
await media.InitializeAsync();
isInit = true;
capturePreview.Source = media;
await media.StartPreviewAsync(); // Ok
}
// ------------------------------------------
void f() {
StaticClass.g(capturePreview.Source);
}
public static class StaticClass {
public static async void g(MediaSource source) {
await media.InitializeAsync();
isInit = true;
source = media;
await media.StartPreviewAsync(); // Unknown Exception (It's seems that media isn't init)
}
}