API からダウンロードしたデータを使用しようとしています。私のコードの例:
private int id;
public MainPage()
{
InitializeComponent();
SomeFunction();
}
public void SomeFunction()
{
DownloadFromAPI("url to api");
MessageBox.Show(id.ToString()); //<< Returns 0
}
public void DownloadFromAPI(DownloadStringCompletedEventArgs url)
{
//code to retrieve data (singel id)
id = Int16.Parse(data);
MessageBox.Show(id.ToString()); //<< Returns the correct number, like 14
test();
}
private void test()
{
MessageBox.Show(id.ToString()); //<< Even Returns the correct number 14
}
終了後にID情報をロードするにはどうすればよいですかDownloadFromAPI("url to api");
。だから私は0の代わりに正しい数字(14)を取得しますか?