예제 #1
0
        private void RefreshServer(TreeNode node)
        {
            var provider = node.Tag as IMetadataProvider;

            if (provider != null)
            {
                UseWaitCursor = true;
                try
                {
                    node.Nodes.Clear();
                    node.Nodes.Add("Refreshing...");
                    ThreadPool.QueueUserWorkItem(o =>
                    {
                        try
                        {
                            provider.Refresh();
                            BeginInvoke(new Action(() =>
                            {
                                var treeNodeWithConnectionInfo = node as TreeNodeWithConnectionInfo;
                                if (treeNodeWithConnectionInfo != null)
                                {
                                    treeNodesBuilder.RebuildDatabaseNode(node, provider);
                                }
                                else
                                {
                                    node.Nodes.Clear();
                                }

                                UpdateDrawnNodes();
                            }));
                        }
                        catch (FaultException faultEx)
                        {
                            BeginInvoke(new Action(() => MessageBox.Show(this, faultEx.Message)));
                        }
                        catch (MessageSecurityException ex)
                        {
                            BeginInvoke(new Action(() => MessageBox.Show(this, ex.Message)));
                        }
                        catch (Exception ex)
                        {
                            BeginInvoke(new Action(() => MessageBox.Show(this, ex.Message)));
                        }
                    });
                }
                finally
                {
                    UseWaitCursor = false;
                }
            }
        }