public MainPage()
{
InitializeComponent();
this.Loaded += new RoutedEventHandler(MainPage_Loaded);
}
void MainPage_Loaded(object sender, RoutedEventArgs e)
{
Verdienen v = new Verdienen(4, 3);
}
然後: 公共Verdienen(INT attesaInSecondiIniziale = 20,INT attesaInSecondiFinale = 8) { this.AttesaInSecondiIniziale = attesaInSecondiIniziale; this.AttesaInSecondiIniziale = attesaInSecondiFinale; MostraPerQuestaSezione = false;
popup = new Popup();
Border border = new Border();
border.Background = new SolidColorBrush(Colors.LightGray);
border.Margin = new Thickness(3);
StackPanel panelVerticale = new StackPanel();
panelVerticale.Orientation = Orientation.Vertical;
AdControl control = new AdControl();
panelVerticale.Children.Add(control);
StackPanel panelOrizzontale = new StackPanel();
panelOrizzontale.Orientation = Orientation.Horizontal;
Button bAltreApp = new Button();
bAltreApp.Content = "";
bAltreApp.Tap += new EventHandler<GestureEventArgs>(bAltreApp_Tap);
Button bVota = new Button();
bVota.Tap += new EventHandler<GestureEventArgs>(bVota_Tap);
bVota.Content = "";
panelOrizzontale.Children.Add(bAltreApp);
panelOrizzontale.Children.Add(bVota);
panelVerticale.Children.Add(panelOrizzontale);
border.Child = panelVerticale;
popup.Child = border;
this.ShowPopup();
}
private async **System.Threading.Tasks.TaskEx** ShowPopup()
{
do
{
Debug.WriteLine("thread iniziato. pausa cominciata");
await System.Threading.Tasks.TaskEx.Delay(1000 * this.AttesaInSecondiIniziale);
Debug.WriteLine("thread: fine pausa");
popup.IsOpen = true;
await System.Threading.Tasks.TaskEx.Delay(1000 * this.AttesaInSecondiFinale);
popup.IsOpen = false;
} while (MostraPerQuestaSezione);
}
請問我爲什麼這段代碼不顯示彈出窗口?注意:一些不必要的代碼不存在! 編輯:請注意,System.Threading.Tasks.TaskEx被標記爲錯誤(「異步方法的返回狀態必須爲無效,任務或任務」)。
凡ShowPopup的代碼? – zzfima 2013-03-27 16:13:57
我已經升級了代碼。請再看一遍! – Spode 2013-03-28 10:53:54