我有这个代码:
private async Task<DataSharedTheatres.TheatresPayload> GetTheatres()
{
var callMgr = new ApiCallsManager();
var fileMgr = new FileSystemManager();
string cachedTheatres = fileMgr.ReadFile(Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "TheatreTemp.txt"));
if (string.IsNullOrEmpty(cachedTheatres))
{
**string generalModelPull = await callMgr.GetData(new Uri("somecrazyapi.com/api" + apiAccessKey));**
bool saveResult = fileMgr.WriteToFile(Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "TheatreTemp.txt"), generalModelPull);
if (!saveResult)
{
testText.Text = "Failed to load Theatre Data";
return null;
}
cachedTheatres = fileMgr.ReadFile(Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "TheatreTemp.txt"));
}
return Newtonsoft.Json.JsonConvert.DeserializeObject<DataSharedTheatres.TheatresPayload>(cachedTheatres);
**}**
Run Code Online (Sandbox Code Playgroud)
我在第一个突出显示的行(它命中)上设置了断点,然后按F10,调试器跳转到最后一个括号!我不明白为什么.
GetData方法:
public async Task<string> GetData(Uri source)
{
if (client.IsBusy)
client.CancelAsync ();
string result = await client.DownloadStringTaskAsync (source);
return result;
}
Run Code Online (Sandbox Code Playgroud)