Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. WaitForSingleObject() Question Again!!!!

WaitForSingleObject() Question Again!!!!

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++announcementlearning
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Richard Cheng
    wrote on last edited by
    #1

    I'm developing a program required to use Synchronization function WaitForSingleObject(). It may take several seconds or longer to run this function, therefore, I want to add a Progress Bar control to let the user knows how long do they need to wait. However, I cannot find the source code of this WaitForSingleObject() function, so I cannot put the progress bar SetPos() in that function. I've tried to set the progress bar move by timer...but when the program run WaitForSingleObject(), the progress bar stopped and start move again after WaitForSingleObject(). Can I do it in this way???:: If originally the timeout value is 16000....(WaitForSingleObject(xxxx, 16000)), then I split it into ... let say....5 ......e.g.: WaitForSingleObject(xxxx, 3200); Call ProgressBarControl; WaitForSingleObject(xxxx, 3200); Call ProgressBarControl; WaitForSingleObject(xxxx, 3200); Call ProgressBarControl; WaitForSingleObject(xxxx, 3200); Call ProgressBarControl; WaitForSingleObject(xxxx, 3200); Call ProgressBarControl; So that the progress bar can update every 3200 time interval?..... Or do anyone have another suggestion on using WaitForSingleObject with Progress Bar?? I must use this WaitForSingleObject function...... Sorry...I just a beginner in MFC programming;P

    J 1 Reply Last reply
    0
    • R Richard Cheng

      I'm developing a program required to use Synchronization function WaitForSingleObject(). It may take several seconds or longer to run this function, therefore, I want to add a Progress Bar control to let the user knows how long do they need to wait. However, I cannot find the source code of this WaitForSingleObject() function, so I cannot put the progress bar SetPos() in that function. I've tried to set the progress bar move by timer...but when the program run WaitForSingleObject(), the progress bar stopped and start move again after WaitForSingleObject(). Can I do it in this way???:: If originally the timeout value is 16000....(WaitForSingleObject(xxxx, 16000)), then I split it into ... let say....5 ......e.g.: WaitForSingleObject(xxxx, 3200); Call ProgressBarControl; WaitForSingleObject(xxxx, 3200); Call ProgressBarControl; WaitForSingleObject(xxxx, 3200); Call ProgressBarControl; WaitForSingleObject(xxxx, 3200); Call ProgressBarControl; WaitForSingleObject(xxxx, 3200); Call ProgressBarControl; So that the progress bar can update every 3200 time interval?..... Or do anyone have another suggestion on using WaitForSingleObject with Progress Bar?? I must use this WaitForSingleObject function...... Sorry...I just a beginner in MFC programming;P

      J Offline
      J Offline
      JoeBloggs
      wrote on last edited by
      #2

      Instead of WaitForSingleObject could you not use MsgWaitForMultipleObject just before the thread is about to do it's stuff create a Timer that fires every second. when MsgWaitForMultipleObjects returns determine what's happened has the thread finished or do you have a windows msg i.e. WM_TIMER. if this is appropriate you could have a class variable that indicates what step the thread is up to - wrapped by a CriticalSection so you can update your UI accordingly.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups