How do I Suspend a Thread on itself

This is a discussion on How do I Suspend a Thread on itself within the Windows Programming forums, part of the Platform Specific Boards category; Note: Using MFC I am wanting a thread to suspend itself and then later from another thread resume it. I ...

  1. #1
    Registered User
    Join Date
    Aug 2001
    Location
    Fort Worth, TX
    Posts
    53

    How do I Suspend a Thread on itself

    Note: Using MFC

    I am wanting a thread to suspend itself and then later from another thread resume it.

    I tried some diffrent code and the thread kept executing, I need it to stop until I resume it from the other thread.

    code below is what I tried

    *static*/ UINT CBintodumpDlg::ThreadProc (LPVOID pParam)
    {
    THREADPARMS *ptp = (THREADPARMS*)pParam;

    Do Stuff

    I tried this

    //ptp->thread points to this thread
    //ptp->thread->SuspendThread(); // program bombs
    //CWinThread::SuspendThread(); // program bombs
    //SuspendThread(NULL); //continues processing,
    //why does this require a
    // parameter?
    //SuspendThread(ptp->thread); //programbombs

    Do More Stuff

    delete ptp;
    return 0;
    }

  2. #2
    Registered User
    Join Date
    Aug 2001
    Location
    Fort Worth, TX
    Posts
    53
    I have found a temporary solution, If anyone is able to help me with the SuspendThread problem I would really appreciate it. Thank you.

    Temp Solution:

    //crappy because it is busy waiting, but works for now

    //do stuff
    while(!ptp->has_format) // flag to signal status
    Sleep(0);

    //do more stuff

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Thread Synchronization in Win32
    By passionate_guy in forum C Programming
    Replies: 0
    Last Post: 02-06-2006, 05:34 AM
  2. [code] Win32 Thread Object
    By Codeplug in forum Windows Programming
    Replies: 0
    Last Post: 06-03-2005, 04:55 PM
  3. Win32 Thread Object Model Revisted
    By Codeplug in forum Windows Programming
    Replies: 5
    Last Post: 12-15-2004, 08:50 AM
  4. Simple thread object model (my first post)
    By Codeplug in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2004, 11:34 PM
  5. Problem : Threads WILL NOT DIE!!
    By hanhao in forum C++ Programming
    Replies: 2
    Last Post: 04-16-2004, 02:37 PM

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