コード例 #1
0
        private void loadQuestion()
        {
            GetQuestionRequest getQuestionRequest = new GetQuestionRequest();

            app.communicator.SocketSendReceive(JsonSerializer.serializeRequest(getQuestionRequest, Constants.GET_QUESTION_REQUEST)).ContinueWith(task =>
            {
                ResponseInfo response = task.Result;
                GetQuestionResponse getQuestionResponse = JsonDeserializer.deserializeResponse <GetQuestionResponse>(response.buffer);

                switch (getQuestionResponse.status)
                {
                case Constants.GET_QUESTION_SUCCESS:

                    this.Dispatcher.Invoke(() =>
                    {
                        LoadQuestionToUI(getQuestionResponse);
                    });
                    break;

                case Constants.GET_QUESTION_FINISHED:
                    thr.Abort();
                    MyMessageQueue.Enqueue("You finished!");
                    this.Dispatcher.Invoke(() =>
                    {
                        NavigationService ns = NavigationService.GetNavigationService(this);
                        ns.Navigate(new Uri("LeaderboardScreen.xaml", UriKind.Relative));
                    });
                    break;
                }
            });
        }
コード例 #2
0
 private void LoadQuestionToUI(GetQuestionResponse response)
 {
     questionTime           = response.questionTime;
     QuestionsCountTXT.Text = response.currentQuestion + "/" + response.totalQuestions;
     Answer1BTN.Content     = response.answers[0];
     Answer2BTN.Content     = response.answers[1];
     Answer3BTN.Content     = response.answers[2];
     Answer4BTN.Content     = response.answers[3];
     questionTXT.Text       = response.question;
     thr = new Thread(new ThreadStart(this.timerThread));
     thr.IsBackground = true;
     thr.Start();
     enableAllButtons();
 }