MS VC++.NET 'release' command?

  • Thread starter Thread starter Peteroid
  • Start date Start date
P

Peteroid

I have a process that takes a long (i.e., sometimes minutes) to accomplish,
and I'd rather not write it as a 'time-slicing' process. Is there some sort
of Windows call that will allow this process to release the CPU for other
processes, yet will return where it left off auomatically? I use to program
in Visual Basic, and think there was something sort of "release" command
that did this.Or does MS VC++.NET already do this automatically (i.e., time
slice the execution to allow for other processes)?

Thanks in advance! :)

[==Peteroid==]
 
Peteroid said:
I have a process that takes a long (i.e., sometimes minutes) to accomplish,
and I'd rather not write it as a 'time-slicing' process. Is there some
sort
of Windows call that will allow this process to release the CPU for other
processes, yet will return where it left off auomatically? I use to
program
in Visual Basic, and think there was something sort of "release" command
that did this.Or does MS VC++.NET already do this automatically (i.e.,
time
slice the execution to allow for other processes)?

The bad old days of a decade ago when 16 bit Windows applications could run
as long as they wanted without giving up the processor are long gone. These
days all of the 32 bit Windows platforms (9x,NT/XP) include a pre-emptive
scheduler so that 32 bits applications don't often have to consider what
else is running on the same box.

There is still some "weirdness" with respect to 16 bit applications on 9x
but as this is a .Net group and as .Net provides no support for 16 bit
applications it shouldn't matter.

Regards,
Will
 
Peteroid said:
I have a process that takes a long (i.e., sometimes minutes) to accomplish,
and I'd rather not write it as a 'time-slicing' process. Is there some sort
of Windows call that will allow this process to release the CPU for other
processes, yet will return where it left off auomatically? I use to program
in Visual Basic, and think there was something sort of "release" command
that did this.Or does MS VC++.NET already do this automatically (i.e., time
slice the execution to allow for other processes)?


In .NET check the classes Monitor and Thread.
 
Peteroid said:
I have a process that takes a long (i.e., sometimes minutes) to accomplish,
and I'd rather not write it as a 'time-slicing' process. Is there some sort
of Windows call that will allow this process to release the CPU for other
processes, yet will return where it left off auomatically? I use to program
in Visual Basic, and think there was something sort of "release" command
that did this.Or does MS VC++.NET already do this automatically (i.e., time
slice the execution to allow for other processes)?

It does it automatically, but I suggest you run your process at a low
priority to prevent it from causing problems with the responsiveness of
windows. Look up thread and process priority in the docs.

Tom
 
Try Sleep(1) somewhere in your loop. Run your program and watch in Task
Manager that CPU usage will be significantly lower and your computer will be
much more responsize.
 
Back
Top