1
Ce que je veux faire est un arrière-plan en direct pour mon menu principal tic tac toe qui devrait mettre Xs et Os au hasard dans n'importe quel bouton ce qui se passe est que le programme gèle et quand j'ai essayé le code le répartiteur ne s'excutedWindows téléphone live background
public partial class MainPage : PhoneApplicationPage
{
Random random;
private Button[] bts;
private int counter;
public MainPage()
{
InitializeComponent();
counter = 0;
bts = new[] { _1, _2, _3, _4, _5, _6, _7, _8, _9 };
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
NavigationService.Navigate(new Uri("/Page1.xaml", UriKind.Relative));
}
private void Button_Click_2(object sender, RoutedEventArgs e)
{
NavigationService.Navigate(new Uri("/Page3.xaml", UriKind.Relative));
}
private void About_Click(object sender, RoutedEventArgs e)
{
NavigationService.Navigate(new Uri("/Page4.xaml", UriKind.Relative));
}
private void form_Loaded(object sender, RoutedEventArgs e)
{
random = new Random();
while (true)
{
Dispatcher.BeginInvoke(()=>
{
bts[random.Next() % 9].Content = (counter % 2 == 0) ? "O" : "X";
counter++;
});
}
}
}
ywa mais je veux continuer à mettre X et Os jusqu'à ce que l'utilisateur clique sur un bouton que dois-je faire ?? c'est la question –
@AmgadSerry: Utilisez une minuterie. – SLaks
http://msdn.microsoft.com/fr-fr/library/system.windows.threading.dispatchertimer.aspx – SLaks