Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / June 2004

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bmwrob - 28 Jun 2004 13:03 GMT
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
William DePalo [MVP VC++] - 29 Jun 2004 05:16 GMT
> 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
bmwrob - 30 Jun 2004 06:02 GMT
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:

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.