AbduallahMohsen

Untitled

Feb 16th, 2021
836
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.97 KB | None | 0 0
  1. using System;
  2. using System.Threading;
  3. using System.Windows.Forms;
  4.  
  5. namespace WindowsFormsApp2
  6. {
  7.     public partial class Form1 : Form
  8.     {
  9.         public Thread Working;
  10.         public Form1()
  11.         {
  12.             InitializeComponent();
  13.             Working = new Thread(new ThreadStart(ThreadActions));
  14.             Working.Start();
  15.         }
  16.         private void ThreadActions()
  17.         {
  18.             while (true)
  19.             {
  20.                 if (DateTime.Now.Hour == 8 && DateTime.Now.Minute <= 30 && !button1.Visible)
  21.                     button1.Visible = true;
  22.                 else if (button1.Visible)
  23.                     button1.Visible = false;
  24.  
  25.                 if ((DateTime.Now.Hour == 12 && DateTime.Now.Minute >= 30 || DateTime.Now.Hour == 13) && !button2.Visible)
  26.                     button2.Visible = true;
  27.                 else if (button2.Visible) button2.Visible = false;
  28.  
  29.                 Thread.Sleep(2000);
  30.             }
  31.         }
  32.     }
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment