![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 | |
|
Programmer
Join Date: Aug 2005
Posts: 68
Rep Power: 4
![]() |
Quote:
Thanks, Leslie |
|
|
|
|
|
|
#12 | |
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,209
Rep Power: 5
![]() |
Quote:
Making an application multi-threaded is more than just setting a few project options. It is also necessary to break up your code so parts can be executed on different threads, create the threads, define mechanisms to synchronise sharing of data between threads, (optionally) move threads to particular processors, handle the results when a thread terminates, etc etc. |
|
|
|
|
|
|
#13 |
|
Hobbyist Programmer
Join Date: Jun 2006
Location: Ireland
Posts: 152
Rep Power: 3
![]() |
Threading isn't something you can turn on and off like that. I suspect the setting you're thinking of is for linking against thread safe runtime or not. At least that would be the case for native applications, but I'm not familiar enough with .NET to know if those settings still apply.
It is reasonably safe to assume that if you are not actively using multiple threads yourself then that is not the issues so that bring us back to what has already been said- If the "quite long and complicated code" takes longer than X seconds to run then there is nothing you can do, if it doesn't then Sleep() will work if it's used correctly. Edit - Replied same time as Grumpy so repeated some of what he said.
__________________
Visit my website BinaryNotions. |
|
|
|
|
|
#14 |
|
Programmer
Join Date: Aug 2005
Posts: 68
Rep Power: 4
![]() |
OK, this is getting weird. The Sleep() function does work, but only in the followng case :
#include ...
using ...
int main(array<System::String ^> ^args)
{
Sleep(5000);
for(...)
{
...***THE CODE***
}
}but not in this case : #include ...
using ...
int main(array<System::String ^> ^args)
{
for(...)
{
Sleep(5000);
...***THE CODE***
}
}In the first case, it does sleep 5 seconds at 0 percent CPU power, whereas in the second it is constantly at 50 percent. What can the problem be? Thank you, Leslie |
|
|
|
|
|
#15 |
|
Hobbyist Programmer
Join Date: Jun 2006
Location: Ireland
Posts: 152
Rep Power: 3
![]() |
Yep that is odd. In the second case it must surely at least sleep for an initial 5 seconds. If after that it never seem to sleep again it has to be that ***THE CODE*** never actually stops working so hence there isn't ever a second iteration of the for loop.
__________________
Visit my website BinaryNotions. |
|
|
|
|
|
#16 |
|
Programmer
Join Date: Aug 2005
Posts: 68
Rep Power: 4
![]() |
The ***CODE*** gives accurate and good results, meaning that it does iterate the number of times defined. However, as you said, it doesn't sleep, even for the first time.
|
|
|
|
|
|
#17 |
|
Hobbyist Programmer
Join Date: Jun 2006
Location: Ireland
Posts: 152
Rep Power: 3
![]() |
To be honest I'm a bit stumped. And I really just don't know enough about .NET to offer alternatives but if you read this msdn link on timers I'm sure you'll be able to figure something to, there's lots of sample code.
__________________
Visit my website BinaryNotions. |
|
|
|
|
|
#18 |
|
Troll
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4
![]() |
The example that you posted should not stay at half utilization. It should drop to zero for five seconds at a time with spikes during ***THE CODE***. Have you set breakpoints or added debugging output in useful places to tell what's actually happening?
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270 |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| FFT DWTIB -> Optimization -> Choosing An Appropriate Run Time | Sane | Software Design and Algorithms | 7 | Dec 1st, 2006 10:40 AM |
| Show or hiding forms/modifying control properties ..from different a form.. | cloud- | C# | 4 | Nov 10th, 2006 10:51 AM |
| Form Submit Blues | MegaArcon | Python | 3 | Dec 14th, 2005 4:20 PM |
| .NET Timer Form closing issue | MBirchmeier | C# | 4 | Nov 21st, 2005 10:00 AM |
| entering data into excel from a form | glevine | Perl | 1 | Nov 18th, 2005 5:03 PM |