private void CheckStateBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            var list = e.Argument as List <IFeatureTypeInfo>;

            SetLoadingToolStripStatusLabelText("...Loading");

            for (var i = 0; i < list.Count; i++)
            {
                var i1 = i;
                try
                {
                    SetCurrentGridRowSelection(i1);

                    getLayerStatusUseCase.Execute(new GetFeatureTypeInfoStatusRequest {
                        Layer = list[i]
                    },
                                                  response => GetLayerStatusHandler(response, i1, list));

                    Thread.Sleep(1000);
                    CheckStateBackgroundWorker.ReportProgress(((i + 1) * 100) / list.Count);
                }
                catch (Exception exception)
                {
                    if (!IsDisposed)
                    {
                        MessageBox.Show(exception.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    e.Cancel = true;
                    return;
                }
            }
        }
 private void CheckAllLayersState()
 {
     if (LayersGrid.DataSource != null && !CheckStateBackgroundWorker.IsBusy)
     {
         var list = LayersGrid.DataSource as IEnumerable <IFeatureTypeInfo>;
         bt_check_state.Enabled    = false;
         bt_upload_missing.Enabled = false;
         pb_load_layers.Visible    = true;
         CheckStateBackgroundWorker.RunWorkerAsync(list);
     }
     else
     {
         MessageBox.Show("Can't do that right now!", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
 private void LayersForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     pb_load_layers.Dispose();
     CheckStateBackgroundWorker.Dispose();
     Dispose();
 }