Me.BackColor = System.Drawing.Color.OrangeRed
Imports System.Threading.TasksPublic Class Form1 Private Sub btnError_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnError.Click Me.BackColor = Color.OrangeRed 'Cambia el color del Form btnError.Enabled = False 'Deshabilita el Botón '<Inicia un subproceso> Task.Factory.StartNew(Sub() Dim Segundos As Integer = 5 System.Threading.Thread.Sleep(Segundos * 1000) 'Espera 5 segundos Me.Invoke(Sub() Me.BackColor = SystemColors.Control) 'Recupera el color del Form Me.btnError.Invoke(Sub() Me.btnError.Enabled = True) 'Vuelve a habilitar el botón End Sub) Me.Width = 500 Label1.Text = "Task genera un subproceso que se produce de forma independente" & Environment.NewLine _ & "El evento Click lo ha iniciado y pasa a la línea siguiente para mostrar este texto" End SubEnd Class