Creating a background thread

using System.Threading;

	//----- START OUR HIGH PRIORITY BACKGROUND THREAD -----
	//This thread is going to run in the background
	Thread newThread = new Thread(MyBackgroundThread);
	newThread.Priority = ThreadPriority.Highest;	//<<Set as needed
	newThread.Start();


	//************************************************
	//********** BACKGROUND LOOPING THREAD ***********
	//************************************************
	private void MyBackgroundThread()
	{
		while (true)
		{
			try
			{

				Thread.Sleep(1000);        //Delay in mS


					
			}
			catch (Exception )
			{

			}
		} //while (true)
	}

Creating an accurate timer based looping background thread

See here.

Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published. Required fields are marked *