Use C # Thread regularly updated using a background thread threads using the Thread

th static the Thread Private; 
 
        /// <Summary>
        /// initialization
        /// </ Summary>
        public static void the Init ()
        {
            th = new new the Thread (ThFun);
            th.IsBackground = to true; // set the background thread
            th .start ();
        } 
        Private static void ThFun ()
        {
            the try
            {
                the while (to true)
                { 
                    // perform a method ();
                    the Thread.Sleep (300000); // refreshed every five minutes in milliseconds
                }
            }
            the catch {}
        }

 


Original: https: //blog.csdn.net/a770kfof/article/details/53067489 

 

private void ThreadDemo()

{

   new Thread(() =>
            {
                while (true)
                {
                    try
                    {
                        OnThreadCheckUser();//要执行的方法
                    }
                    catch{}
                    Thread.Sleep(1000);
                }
            }) { IsBackground = true }.Start();

}

  void OnThreadCheckUser Private ()
  {
            MessageBox.Show ( "You need content");

  }


 

Guess you like

Origin blog.csdn.net/cn_514/article/details/89670342