示例#1
0
        /// <summary>
        /// Refresh clients list
        /// </summary>
        public void RefreshClients()
        {
#if DEBUG
            // IF debugging, time how long it takes
            var sw = new System.Diagnostics.Stopwatch();
            sw.Start();
#endif
            // Check main app thread isn#t null
            if (System.Windows.Application.Current != null)
            {
                // invoke action on application thread - Must update UI values on this thread
                System.Windows.Application.Current.Dispatcher.Invoke(new Action(() =>
                {
                    var selected = SelectedClient;
                    Clients.Clear();

                    // Clear clients and re-add
                    foreach (var client in m_clientsBL.GetAllRegisteredClients().OrderBy(c => c.Name))
                    {
                        Clients.Add(client);
                    }

                    // re select the selected client
                    if (selected != null)
                    {
                        SelectedClient = Clients.FirstOrDefault(c => c.ClientId == selected.ClientId);
                    }
                }));
            }
#if DEBUG
            // if debugging, show time taken
            sw.Stop();
            System.Diagnostics.Debug.WriteLine("Refresh Client List Time: " + sw.ElapsedMilliseconds + "ms");
#endif
        }
示例#2
0
        public void RefreshClients()
        {
#if DEBUG
            var sw = new System.Diagnostics.Stopwatch();
            sw.Start();
#endif
            if (System.Windows.Application.Current != null)
            {
                System.Windows.Application.Current.Dispatcher.Invoke(new Action(() =>
                {
                    var selected = SelectedClient;
                    Clients.Clear();

                    foreach (var client in m_clientsBL.GetAllRegisteredClients().OrderBy(c => c.Name))
                    {
                        Clients.Add(client);
                    }

                    if (selected != null)
                    {
                        SelectedClient = Clients.FirstOrDefault(c => c.ClientId == selected.ClientId);
                    }
                }));
            }
#if DEBUG
            sw.Stop();
            System.Diagnostics.Debug.WriteLine("Refresh Client List Time: " + sw.ElapsedMilliseconds + "ms");
#endif
        }