async await、一歩一歩試用
2240 ワード
public class downClass1
{
public IStorageFile pResultStorageFile;
public async Task<IStorageFile> down()
{
string CountriesFile = "fruit.xml";
StorageFolder InstallationFolder =Windows.ApplicationModel.Package.Current.InstalledLocation;
StorageFile file = await InstallationFolder.CreateFileAsync(CountriesFile);
BackgroundDownloader ppp = new BackgroundDownloader();
DownloadOperation pDownloadOperation= ppp.CreateDownload(new Uri("http://files.cnblogs.com/gisbeginner/fruit.xml"), file);
await pDownloadOperation.StartAsync();
pResultStorageFile = pDownloadOperation.ResultFile;
return pResultStorageFile;
}
}
}///
istorageFileタイプはTask〈istorageFile〉に返すことができ、このメソッドを呼び出すときIstorageFile pDownLoadFile=pdownClass 1.down() as IStorageFile; これじゃだめだ
public IStorageFile pDownLoadFile;
pDownLoadFile =await pdownClass1.down()、これでいいです
http://msdn.microsoft.com/en-us/library/hh191443(v=vs.110).aspx#Y749