private void BtnDisConnect_Click(object sender, EventArgs e)
 {
     BckGrdWorkerDll.CancelAsync();
     // Loop on TabPages
     for (int index = 0; index < tabControl1.TabPages.Count; index++)
     {
         tabControl1.SelectedIndex = index;
         CloseCurTab();
     }
     listViewPckg.Items.Clear();
     listViewPrjInf.Items.Clear();
     //splitContainer1.Panel2.Controls.Clear();
     panelProjects.Controls.Clear();
     ItemCheckState(false);
     VarGlobal.NetEvManager.DoSomething("Disconnected");
 }
 private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     foreach (TabPage item in tabControl1.TabPages)
     {
         try
         {
             if (item.Name != "TabPgMain")
             {
                 ((Ctrl.BuildPkg)item.Controls[0]).CancelTrafic();
             }
         }
         catch (Exception Ex)
         {
             if (!VarGlobal.LessVerbose)
             {
                 Console.WriteLine(Ex.Message);
             }
         }
         BckGrdWorkerDll.CancelAsync();
     }
     try
     {
         if (CmBxPrjName.AutoCompleteCustomSource.Count > 0)
         {
             GenericXmlSerializer.Serialize(CmBxPrjName.AutoCompleteCustomSource,
                                            VarGlobale.BookMarks);
         }
     }
     catch (Exception Ex)
     {
         if (!VarGlobal.LessVerbose)
         {
             Console.WriteLine("{0}{1}{2}", Ex.Message, Environment.NewLine,
                               Ex.StackTrace);
         }
     }
     Application.ExitThread();
     this.Dispose(true);
 }