{"id":12197,"date":"2021-12-09T00:33:17","date_gmt":"2021-12-09T00:33:17","guid":{"rendered":"https:\/\/lgildv5i97.onrocket.site\/answers\/?post_type=question&#038;p=12197"},"modified":"2021-12-09T00:33:34","modified_gmt":"2021-12-09T00:33:34","slug":"c-timer-to-flash-a-label-on-button-click","status":"publish","type":"question","link":"https:\/\/computing.net\/answers\/programming\/c-timer-to-flash-a-label-on-button-click\/28699.html","title":{"rendered":"C# Timer To Flash a Label On Button Click"},"content":{"rendered":"<p>I have a button that when it is pressed I want to start a timer that flashes a label while the rest of the button1 click event is proccessed. I have read that a timer works on it&#8217;s own thread so I should be able to run both threads asynchronly. As of now the label flashes as expected but it doesn&#8217;t start unting all of the button 1 click is finished. How can I make this work at the same time. I am a newbie so please help.<\/p>\n<p>Here is my code.<\/p>\n<p>using System;<br \/>\nusing System.Collections.Generic;<br \/>\nusing System.ComponentModel;<br \/>\nusing System.Data;<br \/>\nusing System.Drawing;<br \/>\nusing System.Linq;<br \/>\nusing System.Text;<br \/>\nusing System.Diagnostics;<br \/>\nusing System.Data.SqlClient;<br \/>\nusing System.IO;<br \/>\nusing System.Windows.Forms;<br \/>\nusing System.Threading;<\/p>\n<p>namespace WindowsFormsApplication3<br \/>\n{<br \/>\npublic partial class Form1 : Form<br \/>\n{<\/p>\n<p>public Form1()<br \/>\n{<br \/>\nInitializeComponent();<\/p>\n<p>}<\/p>\n<p>private void Form1_Load(object sender, EventArgs e)<br \/>\n{<\/p>\n<p>}<\/p>\n<p>private void button1_Click(object sender, EventArgs e)<br \/>\n{<br \/>\ntimer1.Start();<br \/>\n\/\/do other stuff<br \/>\n}<\/p>\n<p>private void timer1_Tick(object sender, EventArgs e)<br \/>\n{<br \/>\nTransferStatusLabel1.Visible = !TransferStatusLabel1.Visible;<br \/>\n}<\/p>\n<p>}<br \/>\n}<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"iawp_total_views":22},"question-category":[55],"question_tags":[],"class_list":["post-12197","question","type-question","status-publish","hentry","question-category-programming"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question\/12197","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question"}],"about":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/types\/question"}],"author":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/comments?post=12197"}],"wp:attachment":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/media?parent=12197"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question-category?post=12197"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question_tags?post=12197"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}