0
我有以下的任務,我很想初始化一旦應用程序正在運行,並且只是在我App.xaml.cs從App.xaml.cs在Windows Phone上運行任務8
public partial class App : Application
{
public bool ProcessedTask = false;
public List<Item> Items = new List<Item>();
public App()
{
...
// Standard XAML initialization
InitializeComponent();
// NOW HERE I WOULD LIKE TO INVOKE MY TASK
}
public async Task<string> RequestDataTask()
{
HttpClient client = new HttpClient();
Task<string> getStringRequests = client.GetStringAsync("http://test.com/get/");
ItemsRootObject responseObject = Newtonsoft.Json.JsonConvert.DeserializeObject<ItemsRootObject>(getStringRequests);
foreach (Item item in responseObject.rows)
{
Items.Add(item);
}
ProcessedTask = true;
string Message = "Processed Task";
return Message;
}
}
public class ItemsRootObject
{
public List<Item> rows { get; set; }
public bool success { get; set; }
public int code { get; set; }
public string msg { get; set; }
}
public class Item
{
public string value { get; set; }
}
填入值
我已經知道JSON返回和對象是否正確(在定期調用中工作),但我不知道(理解)如何調用我的任務,同時保持電話應用程序正在運行(加載MainPage.xaml)。
任何人都可以告訴我如何異步啓動我的任務?
真棒的感謝! – 2014-09-05 23:22:31