Difference between revisions of "Main Thread"

From cxwiki

(Created page with "<div class="mw-parser-output">The main thread is the primary entry point of any Process. This is the thread on which the main() function is called.</div> <div class="mw-pa...")
 
 
Line 1: Line 1:
<div class="mw-parser-output">The main thread is the primary entry point of any [[Process]]. This is the thread on which the main() function is called.</div> <div class="mw-parser-output">&nbsp;</div> <div class="mw-parser-output">Amongst all threads in the process, it is special in a number of ways:</div>  
+
<div class="mw-parser-output"><div class="mw-parser-output">The main thread is the primary entry point of any [[Process Management|Process]]. This is the thread on which the main() function is called.</div> <div class="mw-parser-output">&nbsp;</div> <div class="mw-parser-output">Amongst all threads in the process, it is special in a number of ways:</div>  
 
*All subsiduary threads must exit before the main thread exits, or undefined behaviour results.  
 
*All subsiduary threads must exit before the main thread exits, or undefined behaviour results.  
 
*The native user interface controls may only be created and accessed on the main thread.  
 
*The native user interface controls may only be created and accessed on the main thread.  
 
*Certain other platform APIs&nbsp;may only be accessed on the main thread.  
 
*Certain other platform APIs&nbsp;may only be accessed on the main thread.  
*[[CXThread]]::GetCurrentThread() returns nullptr for the main thread (but it also does this for other externally-created threads).  
+
*[[CXThread|CXThread]]::GetCurrentThread() returns nullptr for the main thread (but it also does this for other externally-created threads).  
*[[CXThread]]::IsCurrentThreadMainThread() returns true for the main thread only.  
+
*[[CXThread|CXThread]]::IsCurrentThreadMainThread() returns true for the main thread only.  
*The native user interface may stop responding if the main thread becomes blocked. Typically this means that the main thread should ONLY service the native user interface and other very short-running tasks, with the bulk of application logic running on preemptive [[CXThread]]s or possibly cooperative&nbsp;[[CXFiber]]s.  
+
*The native user interface may stop responding if the main thread becomes blocked. Typically this means that the main thread should ONLY service the native user interface and other very short-running tasks, with the bulk of application logic running on preemptive [[CXThread|CXThreads]] or possibly cooperative&nbsp;[[CXFiber|CXFibers]].  
  
 
&nbsp;
 
&nbsp;
  
 
&nbsp;
 
&nbsp;
 +
</div>

Latest revision as of 06:40, 23 February 2018

The main thread is the primary entry point of any Process. This is the thread on which the main() function is called.
 
Amongst all threads in the process, it is special in a number of ways:
  • All subsiduary threads must exit before the main thread exits, or undefined behaviour results.
  • The native user interface controls may only be created and accessed on the main thread.
  • Certain other platform APIs may only be accessed on the main thread.
  • CXThread::GetCurrentThread() returns nullptr for the main thread (but it also does this for other externally-created threads).
  • CXThread::IsCurrentThreadMainThread() returns true for the main thread only.
  • The native user interface may stop responding if the main thread becomes blocked. Typically this means that the main thread should ONLY service the native user interface and other very short-running tasks, with the bulk of application logic running on preemptive CXThreads or possibly cooperative CXFibers.