void TaskScheduler::TaskingThreadFunction( const ThreadArgs& args_ )
{
	CoInitializeEx(NULL, COINIT_MULTITHREADED);
    
    uint32_t threadNum				= args_.threadNum;
	TaskScheduler*  pTS				= args_.pTaskScheduler;
    gtl_threadNum					= threadNum;
	gtl_pCurrTS						= pTS;
	pTS->m_NumThreadsRunning.fetch_add(1, std::memory_order_relaxed );
    
    uint32_t spinCount = 0;
	uint32_t hintPipeToCheck_io = threadNum + 1;	// does not need to be clamped.
    while( pTS->m_bRunning.load( std::memory_order_relaxed ) )
    {
		if( !pTS->TryRunTask( threadNum, hintPipeToCheck_io ) )
		{
			// no tasks, will spin then wait
			++spinCount;
			if( spinCount > SPIN_COUNT )
			{
				pTS->WaitForTasks<false>( threadNum );
			}
		}
		else
		{
			spinCount = 0;
		}
    }

    pTS->m_NumThreadsRunning.fetch_sub( 1, std::memory_order_relaxed );
	gtl_threadNum = NO_THREAD_NUM;
	gtl_pCurrTS   = NULL;
    return;
}