VC++ .NET Windows and interrupts / watchdogs question.

B

bmwrob

I have developed a decoding tool by using MFC (Dialog based) in VS
.NET 2003. The program actually works, but it “hangs” during the
actual decoding. When finished the window comes back again. As the
actual decoding of my file could take up to 5 minutes, this is of
course quite annoying. During the decoding the CPU is more or less
parked at 100%. How can this be avoided? Is it possible in a not too
complex way to have some watchdogs introduced to so e.g. I can pause
the decoding or if wanted and resume later on. As it is know I can’t
even move the “Window” as it’s not updated.

BR /// Rob
 
W

William DePalo [MVP VC++]

bmwrob said:
I have developed a decoding tool by using MFC (Dialog based) in VS
NET 2003. The program actually works, but it “hangs” during the
actual decoding. When finished the window comes back again.

The first commandment of programming Windows is "Thou shalt pump messages".
If you don't retrieve messages from your queue and process them or let
Windows handle them in the default way ( e.g. via DefWindowProc() ) then
your application will appear hung.

A simple solution to a problem like yours is to handle your CPU intensive
task in a secondary (some would say "background" thread) while the main
(a.k.a. "foreground") thread handles the UI issues. Of course then you have
the somewhat thorny issue of how the background thread notifies the
foreground thread of its progress if your UI requires that. In addition, in
some situations in may be wise to lower the priority of the background
thread slightly so that the UI thread can appear responsive to the user at
all times - check the docs for SetThreadPriority().

If anything in the paragraph above is either new to you or not clear, I'd
suggest that you post again in an MFC group.

Regards,
Will
 
B

bmwrob

Well, I must admit everything you wrote was new to me. What I know
about windows programming is what I read in “Learn VC in 21 days” and
in that book I’m only half way! I do get your point though. I realize
that I might have posted in the wrong forum as these questions are
probably very basic for most here. Thanks anyway for the hints. I
will do some search based on what you wrote and see what I come up
with.

BR /// Rob

P.S. what’s the second commandment: ” thy shall not commit adultery
while programming…” :wink:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top