Guest User

Untitled

a guest
Jun 18th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. public partial class frm_Painel_de_Producao : Form
  2. {
  3. frm_Progress_Bar pb = frm_Progress_Bar();
  4.  
  5. private async void btnAtualizaGrid_Click(object sender, EventArgs e)
  6. {
  7.  
  8. pb.Show();
  9.  
  10. //desabilita os botões enquanto a tarefa é executada.
  11. btnCancelar.Enabled = false;
  12. btnIncluir.Enabled = false;
  13. btnAtualizaGrid.Enabled = false;
  14.  
  15. // simply start and await the loading task
  16. await Task.Run(() => carregarGrid());
  17. pb.Close();
  18.  
  19. // habilita os botões após tarefa evento de loading.
  20. btnAtualizaGrid.Enabled = true;
  21. btnCancelar.Enabled = true;
  22. btnIncluir.Enabled = true;
  23.  
  24. }
  25.  
  26. }
  27.  
  28. public partial class frm_Progress_Bar : Form
  29. {
  30. public frm_Progress_Bar()
  31. {
  32. InitializeComponent();
  33.  
  34. }
  35. }
  36.  
  37. public void carregarGrid()
  38. {
  39.  
  40. timer.Interval = 1000;
  41. timer.Tick += meuRelogio;
  42. timer.Start();
  43. dgvProducao.AutoGenerateColumns = false;
  44. dgvProducao.DataSource = clsPPCP.painelProducao();
  45. MeuBD.AbreXML();
  46. if (MeuBD.RequerUsuario == "1")
  47. {
  48. txtOperador.Focus();
  49. }
  50. else
  51. {
  52. txtOperador.Hide();
  53. txtNomeOperador.Hide();
  54. label8.Hide();
  55. txtCartao.Focus();
  56. }
  57. colorirGrid();
  58. //MeuBDex.AbreXML();
  59. relogio();
  60. }
Add Comment
Please, Sign In to add comment