473,325 Members | 2,860 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

loops and ie 7

Hi,
what is the best sleep method when in long
loops , running aspx c# 2.0

i have a situation where i have to loop through a large record set, and
there is no background thread,
just code ran from the update button

is threading.sleep(0) the best option

thanks
DaveL
Aug 16 '08 #1
4 1024
DaveL wrote:
what is the best sleep method when in long
loops , running aspx c# 2.0

i have a situation where i have to loop through a large record set, and
there is no background thread,
just code ran from the update button

is threading.sleep(0) the best option
What good should that do ?

The browser will not get anything until you are done.

And the scheduler will give the CPU to other processes/threads
anyway.

Arne
Aug 16 '08 #2
its not my code....its a code workers..and he is having problems with cpu
spiking

i dont know the answer, thats why im asking here

DaveL

"Arne Vajhøj" <ar**@vajhoej.dkwrote in message
news:48***********************@news.sunsite.dk...
DaveL wrote:
>what is the best sleep method when in long
loops , running aspx c# 2.0

i have a situation where i have to loop through a large record set, and
there is no background thread,
just code ran from the update button

is threading.sleep(0) the best option

What good should that do ?

The browser will not get anything until you are done.

And the scheduler will give the CPU to other processes/threads
anyway.

Arne

Aug 16 '08 #3
DaveL wrote:
"Arne Vajhøj" <ar**@vajhoej.dkwrote in message
news:48***********************@news.sunsite.dk...
>DaveL wrote:
>>what is the best sleep method when in long
loops , running aspx c# 2.0

i have a situation where i have to loop through a large record set, and
there is no background thread,
just code ran from the update button

is threading.sleep(0) the best option
What good should that do ?

The browser will not get anything until you are done.

And the scheduler will give the CPU to other processes/threads
anyway.
its not my code....its a code workers..and he is having problems with
cpu
spiking

i dont know the answer, thats why im asking here
If you do some Thread.Sleep calls, then that thread will
probably give more CPU to other reads, but it will also
run longer so if there are requests in parallel the
CPU usage will be the same. And you will use more threads.

I think you need to attack the core problem and reduce the
CPU usage of the code.

Arne
Aug 16 '08 #4
DaveL wrote:
its not my code....its a code workers..and he is having problems with cpu
spiking

i dont know the answer, thats why im asking here

DaveL

"Arne Vajhøj" <ar**@vajhoej.dkwrote in message
news:48***********************@news.sunsite.dk...
>DaveL wrote:
>>what is the best sleep method when in long
loops , running aspx c# 2.0

i have a situation where i have to loop through a large record set, and
there is no background thread,
just code ran from the update button

is threading.sleep(0) the best option
What good should that do ?

The browser will not get anything until you are done.

And the scheduler will give the CPU to other processes/threads
anyway.

Arne
How large is the result, really? Millions of records?

What is the reason that you have to loop through a large recordset in
the first place? You can hardly display all the data on the page anyway,
and even if you did, most of the time would still be cosumed getting the
data from the database, and getting the page to the user.

Have you considered if the database can do some of the work? If you are
comparing the data in some way, that's what the database is built for,
and it usually does it much better.

If you really have to do a lot of work, what is the problem with the CPU
spiking? That's what it does when it works. Code runs at the maximum
speed all the time, the only reason that you don't see spikes all the
time is that they are too short to show up.

--
Göran Andersson
_____
http://www.guffa.com
Aug 16 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Oleg Leschov | last post by:
Could there be means of exiting nested loops in python? something similar to labelled loops in perl.. I consider it irrating to have to make a flag for sole purpose of checking it after loop if...
15
by: JustSomeGuy | last post by:
I have a need to make an applicaiton that uses a variable number of nested for loops. for now I'm using a fixed number: for (z=0; z < Z; ++z) for (y=0; y < Y; ++y) for (x=0; x < X; ++x)
4
by: Dr. David Kirkby | last post by:
I have a program that loops through and changes all the elements on an array n times, so my code looks like this: for (n=1; n < n_max; ++n) for(i=imax; i >= 0; --i) { for(j=0 ; j < jmax; ++j) {...
46
by: Neptune | last post by:
Hello. I am working my way through Zhang's "Teach yourself C in 24 hrs (2e)" (Sam's series), and for nested loops, he writes (p116) "It's often necessary to create a loop even when you are...
6
by: Scott Brady Drummonds | last post by:
Hi, everyone, I was in a code review a couple of days ago and noticed one of my coworkers never used for() loops. Instead, he would use while() loops such as the following: i = 0; while (i...
17
by: John Salerno | last post by:
I'm reading Text Processing in Python right now and I came across a comment that is helping me to see for loops in a new light. I think because I'm used to the C-style for loop where you create a...
10
by: Putty | last post by:
In C and C++ and Java, the 'for' statement is a shortcut to make very concise loops. In python, 'for' iterates over elements in a sequence. Is there a way to do this in python that's more concise...
2
by: bitong | last post by:
I'm a little bit confuse with regard to our subject in C..We are now with the Loops..and I was just wondering if given a problem, can you use Do-while loops instead of a for loops or vise versa? are...
3
by: monomaniac21 | last post by:
hi all i have a script that retrieves rows from a single table, rows are related to eachother and are retrieved by doing a series of while loops within while loops. bcos each row contains a text...
8
by: Nathan Sokalski | last post by:
I have several nested For loops, as follows: For a As Integer = 0 To 255 For b As Integer = 0 To 255 For c As Integer = 0 To 255 If <Boolean ExpressionThen <My CodeElse Exit For Next If Not...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.