0
我在我的頁面上有異步呼叫, 這大約需要1分鐘。 我需要在呼叫完成後更改UI。 示例代碼如下。如何在異步調用後更改我的頁面的UI?
protected void Unnamed1_Click(object sender, EventArgs e)
{
apicasystemWPMCheckStatsService.CheckStatsServiceClient obj = new apicasystemWPMCheckStatsService.CheckStatsServiceClient();
string xmlOptionForGetCheckStats = "<options><mostrecent count='1'/><dataformat>xml</dataformat><timeformat>tz</timeformat></options>";
string checkId = "";
TextBox1.Text = TextBox1.Text + "test" + "\r\n";
obj.BeginGetCheckStats("[email protected]", "Cu4snfPSGr8=", "PD6B685A0-006A-4405-951E-B24BB51E7966",
checkId, xmlOptionForGetCheckStats, new AsyncCallback(ONEndGetCheckStats), null);
TextBox1.Text = TextBox1.Text + "testdone" + "\r\n";
}
public void ONEndGetCheckStats(IAsyncResult asyncResult)
{
System.Threading.Thread.Sleep(3000);
TextBox1.Text = TextBox1.Text + "testcomplete" + "\r\n";
}
問題是,我怎樣才能在我的文本框中獲得「testcomplete」。因爲我的網頁是沒有得到登載異步調用後回....
我現在的O/P: 測試 testdone
預計: 測試 testdone testcomplet
嘿,Juhan,我知道這件事,順便說一句,這只是示例代碼,所以我的按鈕名稱是不正確的,在WebMethod我無法訪問控件。和我的網頁有3-4個用戶控件和訪問這些和代碼也很複雜,所以我需要一些其他方式。 –
事情是,COntrol正在受到影響,就像我的文本框有Text屬性來「測試testdone testcomplet」,但概率是由於頁面沒有刷新測試完成,從來沒有進入文本框!!!!!你明白我的意思了嗎? –