Thread: In trouble with CreateThread

  1. #1
    Registered User
    Join Date
    Aug 2007

    Question In trouble with CreateThread

    I am trying to develop a multithreat application but the code below act a bit strange do not call workingThread and giving no error message as well. The code below working well with borland compiler but now I am using vs2003, pls help me, why that code do not work?

    threadId = CreateThread( NULL, 0,
    (LPTHREAD_START_ROUTINE) workingThread,
    0, 0, &dwThreadId);

    SetThreadPriority( threadId, THREAD_PRIORITY_NORMAL);

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Are you checking the return value of CreateThread() to see if it failed? If so, check what error it's giving you with GetLastError().

    Otherwise, are you sure that workingThread points to valid code? Does it have the same calling convention that CreateThread() is expecting? It has to have a prototype like this:

    DWORD WINAPI ThreadProc(LPVOID lpParameter);

  3. #3
    Technical Lead QuantumPete's Avatar
    Join Date
    Aug 2007
    London, UK
    Quote Originally Posted by mindtrap View Post
    multithreat application
    Thas sounds like something to be afraid of...

    "No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
    "Have you tried turning it off and on again?" - The IT Crowd

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. CreateThread() function question
    By chiefmonkey in forum C++ Programming
    Replies: 5
    Last Post: 05-15-2009, 07:52 AM
  2. compiler doesn't like CreateThread
    By finkus in forum C++ Programming
    Replies: 6
    Last Post: 11-30-2005, 03:06 AM
  3. trouble scanning in... and link listing
    By panfilero in forum C Programming
    Replies: 14
    Last Post: 11-21-2005, 12:58 PM
  4. CreateThread and lpParam
    By Hunter2 in forum Windows Programming
    Replies: 6
    Last Post: 06-02-2004, 04:46 PM
  5. C++ program trouble
    By senrab in forum C++ Programming
    Replies: 7
    Last Post: 04-29-2003, 11:55 PM