Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.12 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9.  
  10. namespace WindowsFormsApplication1
  11. {
  12.     public partial class Form1 : Form
  13.     {
  14.         public Form1()
  15.         {
  16.             InitializeComponent();
  17.         }
  18.  
  19.         private void StartThreadButton_Click(object sender, EventArgs e)
  20.         {
  21.             BeginInvoke(new Action(delegate()
  22.             {
  23.                 new TimerLol(delegate()
  24.                 {
  25.                     // update the UI here.
  26.                 });
  27.             }));
  28.         }
  29.     }
  30.  
  31.     public class TimerLol
  32.     {
  33.         private Action callback;
  34.  
  35.         public TimerLol(Action callback)
  36.         {
  37.             this.callback = callback;            
  38.         }
  39.  
  40.         private void TimerLol()
  41.         {
  42.             while (true)
  43.             {
  44.                 if (DateTime.Now == DateTime.Now.AddDays(1)) // futuristic!
  45.                 {
  46.                     callback();
  47.                 }                
  48.             }
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement