In trouble with CreateThread

This is a discussion on In trouble with CreateThread within the C Programming forums, part of the General Programming Boards category; I am trying to develop a multithreat application but the code below act a bit strange do not call workingThread ...

  1. #1
    Registered User
    Join Date
    Aug 2007
    Posts
    18

    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
    Posts
    3,211
    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:

    Code:
    DWORD WINAPI ThreadProc(LPVOID lpParameter);

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

    QuantumPete
    "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, 02:06 AM
  3. trouble scanning in... and link listing
    By panfilero in forum C Programming
    Replies: 14
    Last Post: 11-21-2005, 11:58 AM
  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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21