c# - Interacting between two threads -


I am working on a Winform application, and my goal is to create a label on my form for the user, and three Seconds later make the label invisible. The point here is three seconds. I honestly did not know that this was the right solution to my problem, but I was sleeping for a three-second (system Threading Thread. Sleep (3000) by creating a new thread. .

I can not use the system Threading Thread.Sleep (3000) because it freeze my GUI for 3 seconds!
  Private zero someVoid () {Lbl_authenticationProcess.Text = "credentials have been verified Authentic ... "; thread slaththreadstart = new thread (new threadstart (new thread program)); sleepThreadStart.Start (); // Once three seconds have passed / thread has expired: lbl_authenticationProcess.Visible = false;} Personal Zero new thread_program () {System.Threading.Thread.Sleep (3000);}   

Then, back to my original question. How can I decide when a new thread is completed ( From my main thread), which means three seconds have passed?

And I believe that there are so many.

Now, you have 3 seconds After blocking the entire UI thread to hide a label. If you want, then just user threads. If not from the sleep (3000) form, then, if you have timer :

  system Windows.fms Timers are best by timer = new system. Windows.Forms.Timer (); Timer.Interval = 3000; Timer Tick ​​+ = (S, E) = & gt; {This.lbl_authenticationProcess.Visible = false; Timer.Stop (); } Timer.start ();   

After 3 seconds, the label will disappear. Although you are waiting for it, however, the user can still interact with your app.

Note that should the timer because its tick event is raised on the UI thread, which gives direct access to the control Is allowed. Other timers can work, but should have interaction with the control Awake / begunIncocked D.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -