예제 #1
0
        private static void OpenThreadProc(object o)
        {
            ListSessionsForm form = o as ListSessionsForm;

            if (!form._remoteSessions.OpenServer())
            {
                form.Invoke((MethodInvoker) delegate
                {
                    form.StatusLabel.Text = "无法访问远程会话";
                });
            }
            else
            {
                QuerySessions(form);
            }
        }
예제 #2
0
        private static void QuerySessions(object o)
        {
            ListSessionsForm form = o as ListSessionsForm;

            if (!form.IsDisposed)
            {
                form.Invoke((MethodInvoker) delegate
                {
                    form.SessionListView.BeginUpdate();
                    form.SessionListView.Items.Clear();
                });
                IList <RemoteSessionInfo> list = form._remoteSessions.QuerySessions();
                if (list == null)
                {
                    form.Invoke((MethodInvoker) delegate
                    {
                        form.StatusLabel.Text = "无法枚举远程会话";
                    });
                    return;
                }
                foreach (RemoteSessionInfo item in list)
                {
                    Wts.ConnectstateClass state = item.State;
                    string       text           = (item.DomainName.Length <= 0) ? item.UserName : (item.DomainName + '\\' + item.UserName);
                    ListViewItem value          = new ListViewItem
                    {
                        Text = item.SessionId.ToString()
                    };
                    value.SubItems.Add(state.ToString());
                    value.SubItems.Add(text);
                    value.SubItems.Add(item.ClientName);
                    form.Invoke((MethodInvoker) delegate
                    {
                        form.SessionListView.Items.Add(value);
                    });
                }
                form.Invoke((MethodInvoker) delegate
                {
                    int count             = form.SessionListView.Items.Count;
                    string text2          = count + " 个会话";
                    form.StatusLabel.Text = text2;
                    form.SortListView();
                    form.SessionListView.EndUpdate();
                    form._areQuerying = false;
                });
            }
        }