Exemplo n.º 1
0
        private void LoadMostSearches()
        {
            try
            {
                ExceptionEvents.RetryOnException(3, TimeSpan.FromSeconds(2), () => {
                    Program.Log.Info("Preparing to display most searches");

                    BackGroundWorker.RunWorkAsync <List <string> >(() => GetMostSearches(), (data) => {
                        if (InvokeRequired)
                        {
                            Invoke(new LoadMostSearchesCallBack(LoadMostSearches), new object[] { });
                        }
                        else
                        {
                            int count = 0;
                            foreach (var tag in data)
                            {
                                if (count <= 100)
                                {
                                    FlowPanelMostSearches.Controls.Add(ControlExtensions.LabelMostSearch(tag, count));
                                }
                            }
                            count++;

                            Program.Log.Info("Completed most searches");
                        }
                    });
                });
            }
            catch (Exception ex) { LabelMostSearches.Visible = false; FlowPanelMostSearches.Visible = false; Program.Log.Error("Unable to get most searches", ex); } // Error occurred, so hide controls and skip...
        }