public void RefreshState()
        {
            if (!isRetrievingState)
            {
                isRetrievingState = true;
                RefreshGifImage.StartAnimate();

                DeviceStateTextBlock.Text = "Retrieving state...";
                CommentValueTextBox.IsEnabled = false;
                DeviceStateTextBlock.Foreground = Brushes.Black;

                var apiComponent = new ApiComponent(new Uri(ConfigurationManager.AppSettings["SignboardApiUri"]));

                var task = Task.Factory.StartNew(() =>
                {
                    try
                    {
                        var stateRequest = apiComponent.GetState(MacAddress);

                        this.Dispatcher.Invoke((Action)(() =>
                        {
                            State = stateRequest;
                        }));
                    }
                    catch(Exception)
                    {
                        this.Dispatcher.Invoke((Action)(() =>
                        {
                            MessageBox.Show("An error occurred. Please check the logs.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                            DeviceStateTextBlock.Text = "(Operation Failed)";
                            RetryButton.Visibility = Visibility.Visible;
                            RequestButton.Visibility = Visibility.Collapsed;
                        }));
                    }
                    finally
                    {
                        this.Dispatcher.Invoke((Action)(() =>
                        {
                            RefreshGifImage.StopAnimate();
                        }));

                        isRetrievingState = false;
                    }
                });

            }
        }
        private void RequestClick(object sender, RoutedEventArgs e)
        {
            RequestButton.Content = "Sending...";
            RequestButton.IsEnabled = false;

            Comment = CommentValueTextBox.Text;
            var apiComponent = new ApiComponent(new Uri(ConfigurationManager.AppSettings["SignboardApiUri"]));

            Task.Factory.StartNew(() =>
            {
                try
                {
                    var stateRequest = apiComponent.RequestApproval(Key, MacAddress, Comment);

                    this.Dispatcher.Invoke((Action)(() =>
                    {
                        State = stateRequest;
                    }));
                }
                catch (Exception)
                {
                    this.Dispatcher.Invoke((Action)(() =>
                    {
                        MessageBox.Show("An error occurred. Please check the logs.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    }));
                }
                finally
                {
                    this.Dispatcher.Invoke((Action)(() =>
                    {
                        RefreshGifImage.StopAnimate();
                        RequestButton.Content = "Request";
                        RequestButton.IsEnabled = true;
                    }));

                    isRetrievingState = false;
                }
            });
        }