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