My original code is not dynamic_cast. It is pure casting.. ( C type )
(CTask*)pQueue->Dequeue();