You can’t create a background thread for a task, but you can schedule it via a static RunAsync method on the Windows.System.Threading.ThreadPool class.

Create a high priority thread that runs forever

using System.Diagnostics;


	//----- START OUR HIGH PRIORITY BACKGROUND THREAD -----
	//We don't await it as its goign to run for the lifetime of the application in the background
	Windows.System.Threading.ThreadPool.RunAsync(this.MyHighPriorityBackgroundThread, Windows.System.Threading.WorkItemPriority.High);


		//******************************************************
		//******************************************************
		//********** HIGH PRIORITY BACKGROUND THREAD ***********
		//******************************************************
		//******************************************************
		private void MyHighPriorityBackgroundThread(Windows.Foundation.IAsyncAction action)
		{
			//This thread runs on a high priority task and loops forever
			while (true)
			{
				//DO SOMETHING...


				
			}
		}
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 *