Windows Phone 8 threading Invalid cross-thread access

前端 未结 2 984
攒了一身酷
攒了一身酷 2021-01-23 04:54

I\'m making a Tic-Tac-Toe game for Windows Phone 8 and I want the game to play vs itself as a background for the main menu

private Button[] bts;
private List<         


        
相关标签:
2条回答
  • 2021-01-23 05:30

    You cannot access the UI thread from any other thread directly. So, Encose your UI access code in the Dispatcher.BeginInvoke()

    Dispatcher.BeginInvoke(() =>
        {
            foreach (Button i in bts)
               i.Content = "";
        });
    
    0 讨论(0)
  • 2021-01-23 05:30
    • Make use of Background Worker.

    For Windows Phone 8: http://msdn.microsoft.com/en-us/library/windows/apps/cc221403(v=vs.105).aspx

    0 讨论(0)
提交回复
热议问题