Ejemplo n.º 1
0
        private void ExecLoadCatalogFromServiceCmd(object parameter)
        {
            ClearSectionsContent();

            ThreadPool.QueueUserWorkItem(_ =>
            {
                SetLoadingState(true);

                var source = new WcfClient(ConnectionSettings.Address, ConnectionSettings.Port);

                try
                {
                    var books = source.GetBooks();

                    if (books == null)
                    {
                        MessageBox.Show(loc.CouldNotConnectToService, loc.Error, MessageBoxButton.OK);

                        SetLoadingState(false);
                        return;
                    }

                    if (books.Any())
                    {
                        DistributeBooksToSections(books);
                    }
                }
                catch
                {
                    //toDo: сделать вывод сообщения об ошибке
                }
                finally
                {
                    SetLoadingState(false);
                }
            });
        }