Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Drawing;
- using System.Timers;
- using System.Windows.Forms;
- using Timer = System.Timers.Timer;
- namespace R719ActualizarGUIAppMultithread
- {
- public partial class Principal : Form
- {
- Timer temporizadorColorRojo;
- Timer temporizadorColorVerde;
- public Principal()
- {
- InitializeComponent();
- temporizadorColorVerde = new Timer(3000);
- temporizadorColorVerde.Elapsed += temporizadorColorVerde_Elapsed;
- temporizadorColorVerde.Start();
- temporizadorColorRojo = new Timer(5000);
- temporizadorColorRojo.Elapsed += temporizadorColorRojo_Elapsed;
- temporizadorColorRojo.Start();
- }
- void temporizadorColorVerde_Elapsed(object sender, ElapsedEventArgs evt)
- {
- btnBoton.Invoke(new Action(() => btnBoton.BackColor = Color.Green));
- }
- void temporizadorColorRojo_Elapsed(object sender, ElapsedEventArgs evt)
- {
- btnBoton.Invoke(new Action(() => btnBoton.BackColor = Color.Red));
- }
- private void btnBoton_Click(object sender, EventArgs e)
- {
- Application.Exit();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement