C # Making flashing forms This article describes how to use C # to create a flashing form. Create a new Windows Forms application and add a button click event. All programs are as follows:
Using system;using system.collections.generic;using system.componentmodel;using system.data;using System.Drawing; Using system.linq;using system.text;using system.windows.forms;using system.threading;namespace _2_fun_with_if_else {public partial class Form1:form {public Form1 () {InitializeComponent (); } private void Button1_Click (object sender, EventArgs e) {while (Visible)//Close the form, stop looping {for (int c = 0; c < 254 && Visible; C + +) {this. BackColor = Color.FromArgb (c, 255-c, C); This method specifies a number of three digits: Red/green/blue. Application.doevents (); This statement enables the operating system to perform other operations outside of the program. otherwise//The program will occupy all CPU cycles thread.sleep (3); This statement inserts a delay of 3 milliseconds in the loop. } for (int c = 254, c >= 0 && Visible; c--) {this. BackColor = Color.FromArgb (c, 255-c, C); Application.doevents (); Thread.Sleep (3); } } } }}
Post-run effects
C # making a flashing form