1
之前,我有必要把我的應用程序的快速暫停執行動作(使應用程序欄按鈕)之前,但我不能確定如何最好地做到這一點。基本上很多處理正在另一個線程中發生,但隨後UI被更新。一旦UI被更新,我將滾動控件滾動到特定的透視項。我想停頓約1秒,或但需要多長時間滾動到擺動控制之前的支點項目,才讓應用程序欄按鈕被激活。我該如何做到這一點?我至今如下如何暫停執行動作
// Show image and scroll to start page if needed
if (Viewport != null)
{
Viewport.Source = result;
if (editPagePivotControl != null && editPagePivotControl.SelectedIndex != 0)
{
//Here is where the pivot control is told to move to the first item
// (from the second which it will be on before this happens)
editPagePivotControl.SelectedIndex = 0;
}
//A flag to determine whether the app bar button should be enabled
//How to pause for the time it takes to finish moving
// to the first pivot item?
if (_wasEdited)
((ApplicationBarIconButton)ApplicationBar.Buttons[0]).IsEnabled = true;
}
['System.Threading.Thread.Sleep(/ * milliseconds to wait * /);'](http://msdn.microsoft.com/en-us/library/d00bd51t.aspx) – Sam
@sam oh lawd沒有。只需使用調度程序計時器即可延遲執行特定時間。或者,更好的是,弄清楚如何判斷它何時完成移動。 – Will
@Will嘛總是有[定時器](http://msdn.microsoft.com/en-us/library/system.timers.timer.aspx),但我不認爲這將是值得的OP的情況。 – Sam