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. Two question about window's timer??

Two question about window's timer??

Scheduled Pinned Locked Moved C / C++ / MFC
questionannouncement
6 Posts 5 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.
  • H Offline
    H Offline
    hemouse
    wrote on last edited by
    #1

    Two question: 1. My program must monite the communication port in real-time mode,and display the trend-line in the screen,but when i do another long task,such as copy a big file to the floppy disk, It seem that the program's interface can't updated until this long task has finished, what shoud I do in such case? 2. when I drag another application's window, It seem that the WM_TIMER message only occured after I release the mouse-button,but I don't want this ,what do I do in such case? Thanks a lot!

    RaviBeeR J L H 4 Replies Last reply
    0
    • H hemouse

      Two question: 1. My program must monite the communication port in real-time mode,and display the trend-line in the screen,but when i do another long task,such as copy a big file to the floppy disk, It seem that the program's interface can't updated until this long task has finished, what shoud I do in such case? 2. when I drag another application's window, It seem that the WM_TIMER message only occured after I release the mouse-button,but I don't want this ,what do I do in such case? Thanks a lot!

      RaviBeeR Offline
      RaviBeeR Offline
      RaviBee
      wrote on last edited by
      #2

      hemouse wrote: the program's interface can't updated until this long task has finished, what shoud I do in such case? You should create a thread to perform time consuming tasks (such as the file copy) in the background. Alternatively, you can perform the file copy in small chunks, between which you should flush the Windows message queue. The separate thread is the preferred way. hemouse wrote: when I drag another application's window, It seem that the WM_TIMER message only occured after I release the mouse-button WM_TIMER messages are still being sent as you perform the drag. However, Windows will handle higher priority messages first (eg: WM_MOUSEMOVE). Eventually, all the WM_TIMER messages will be handled as a single one. You need to restructure your logic to account for this. /ravi "There is always one more bug..." http://www.ravib.com ravib@ravib.com

      H 1 Reply Last reply
      0
      • H hemouse

        Two question: 1. My program must monite the communication port in real-time mode,and display the trend-line in the screen,but when i do another long task,such as copy a big file to the floppy disk, It seem that the program's interface can't updated until this long task has finished, what shoud I do in such case? 2. when I drag another application's window, It seem that the WM_TIMER message only occured after I release the mouse-button,but I don't want this ,what do I do in such case? Thanks a lot!

        J Offline
        J Offline
        Joao Vaz
        wrote on last edited by
        #3

        Hi, If you must monitor the communication port in real-time mode, do not use WM_TIMER ! Use waitable timers(check the api SetWaitableTimer) or more precise than this multimedia timers, do a check for this on MSDN. Anyway WM_TIMER is meant to use in user mode gui applications , not on your type of project. I've done this kind of development, and WM_TIMER doesn't work well, it have lower priority than waitable timers and multimedia timers(more precise) Cheers, Joao Vaz

        1 Reply Last reply
        0
        • H hemouse

          Two question: 1. My program must monite the communication port in real-time mode,and display the trend-line in the screen,but when i do another long task,such as copy a big file to the floppy disk, It seem that the program's interface can't updated until this long task has finished, what shoud I do in such case? 2. when I drag another application's window, It seem that the WM_TIMER message only occured after I release the mouse-button,but I don't want this ,what do I do in such case? Thanks a lot!

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          I'm developing sth. similar: Data from Serial is displayed in a diagram. I have a workerthread polling data from serial and adding it to a shreadsave queue. a GDI-thread takes data from the queue and draws a diagramm in the Client area. Re: to hintiflo@gmx.at if you're interested! Don't reply from CP directly, my account doesn't work! mfg HintiFlo

          1 Reply Last reply
          0
          • RaviBeeR RaviBee

            hemouse wrote: the program's interface can't updated until this long task has finished, what shoud I do in such case? You should create a thread to perform time consuming tasks (such as the file copy) in the background. Alternatively, you can perform the file copy in small chunks, between which you should flush the Windows message queue. The separate thread is the preferred way. hemouse wrote: when I drag another application's window, It seem that the WM_TIMER message only occured after I release the mouse-button WM_TIMER messages are still being sent as you perform the drag. However, Windows will handle higher priority messages first (eg: WM_MOUSEMOVE). Eventually, all the WM_TIMER messages will be handled as a single one. You need to restructure your logic to account for this. /ravi "There is always one more bug..." http://www.ravib.com ravib@ravib.com

            H Offline
            H Offline
            hemouse
            wrote on last edited by
            #5

            about first question: perhaps you have misunderstood my meaning. I didn't copy the big file in my application.Instead, I switched to the window's explore to do this task, so my application can't handle something(such as update the interface in real-time , send a signal to the comport's DTR when I received some special bytes from the comport),and these only can do after the file's copying is ended. About question 2: Can you give me some good advices ? :laugh: Have a nice day! No money is a terrible thing!

            1 Reply Last reply
            0
            • H hemouse

              Two question: 1. My program must monite the communication port in real-time mode,and display the trend-line in the screen,but when i do another long task,such as copy a big file to the floppy disk, It seem that the program's interface can't updated until this long task has finished, what shoud I do in such case? 2. when I drag another application's window, It seem that the WM_TIMER message only occured after I release the mouse-button,but I don't want this ,what do I do in such case? Thanks a lot!

              H Offline
              H Offline
              HintiFlo
              wrote on last edited by
              #6

              hemouse wrote: It seem that the program's interface can't updated until this long task has finished, what shoud I do in such case? As I posted, I suggest, updating not via timer, but polling data from a queue in another thread. Maybe it helps if you read my code, I have troubles with painting, so we could exchange our projs. But only if you sware not to laugh about me and my coding "style" :) :) :) :) ! Forget the email I sent yesterday, I'm on track about your question again!

              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