コード例 #1
0
        private void ButtonRefresh_Click(object sender, RoutedEventArgs e)
        {
            var isClearCache = CheckBoxClearCache.IsChecked ?? false;

            new Thread(() =>
            {
                try
                {
                    Dispatcher.Invoke(() =>
                                      settings.Password = ((PasswordBox)((Button)sender).CommandParameter).Password);

                    // PasswordBox doesn't allow 2 way binding, so we have to manually read it
                    settings.Dirty = true;

                    UpdateStatus("Re-initialising data ...", true);
                    InitActions(isClearCache);
                    UpdateStatus("-- Finished re-initialising data ...", false);

                    if (isClearCache)
                    {
                        CrmDataHelper.ClearCache();
                    }
                }
                catch (Exception exception)
                {
                    PopException(exception);
                }
                finally
                {
                    Dispatcher.Invoke(() => CheckBoxClearCache.IsChecked = false);
                    UpdateStatus("", false);
                }
            }).Start();
        }