{"id":1228,"date":"2022-10-06T17:52:27","date_gmt":"2022-10-06T16:52:27","guid":{"rendered":"https:\/\/ibex.tech\/csharp\/?p=1228"},"modified":"2022-10-06T17:52:53","modified_gmt":"2022-10-06T16:52:53","slug":"threads","status":"publish","type":"post","link":"https:\/\/ibex.tech\/csharp\/c-sharp\/threads-c-sharp\/threads","title":{"rendered":".Threads"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Creating a background thread<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>using System.Threading;\n\n\t\/\/----- START OUR HIGH PRIORITY BACKGROUND THREAD -----\n\t\/\/This thread is going to run in the background\n\tThread newThread = new Thread(MyBackgroundThread);\n\tnewThread.Priority = ThreadPriority.Highest;\t\/\/&lt;&lt;Set as needed\n\tnewThread.Start();\n\n\n\t\/\/************************************************\n\t\/\/********** BACKGROUND LOOPING THREAD ***********\n\t\/\/************************************************\n\tprivate void MyBackgroundThread()\n\t{\n\t\twhile (true)\n\t\t{\n\t\t\ttry\n\t\t\t{\n\n\t\t\t\tThread.Sleep(1000);        \/\/Delay in mS\n\n\n\t\t\t\t\t\n\t\t\t}\n\t\t\tcatch (Exception )\n\t\t\t{\n\n\t\t\t}\n\t\t} \/\/while (true)\n\t}<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Creating an accurate timer based looping background thread<\/h4>\n\n\n\n<p>See <a href=\"\/csharp\/c-sharp\/timer-and-timing\/stopwatch-2\">here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Creating a background thread Creating an accurate timer based looping background thread See here.<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[150],"tags":[],"class_list":["post-1228","post","type-post","status-publish","format-standard","hentry","category-threads-c-sharp"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/1228","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/comments?post=1228"}],"version-history":[{"count":2,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/1228\/revisions"}],"predecessor-version":[{"id":1230,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/1228\/revisions\/1230"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/media?parent=1228"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/categories?post=1228"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/tags?post=1228"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}