Click here to Skip to main content
15,893,564 members
Home / Discussions / C#
   

C#

 
GeneralRe: In MSSQL, how to know update query will affect any rows or not. Pin
Christian Graus29-Jan-09 22:48
protectorChristian Graus29-Jan-09 22:48 
GeneralRe: In MSSQL, how to know update query will affect any rows or not. Pin
S a n d y30-Jan-09 21:05
S a n d y30-Jan-09 21:05 
QuestionHow to open a application in IE7 Pin
sw_tech12329-Jan-09 20:06
sw_tech12329-Jan-09 20:06 
AnswerRe: How to open a application in IE7 Pin
justindhas29-Jan-09 23:11
justindhas29-Jan-09 23:11 
GeneralRe: How to open a application in IE7 Pin
sw_tech12330-Jan-09 0:44
sw_tech12330-Jan-09 0:44 
QuestionAccessing webcam parameters such as resulotion and mode Pin
Member 407064129-Jan-09 19:40
Member 407064129-Jan-09 19:40 
QuestionHow to solve delay in display of replaced text on a web page? How to reduce CPU usage which is caused due to 'foreach loop'? Pin
svt gdwl29-Jan-09 18:43
svt gdwl29-Jan-09 18:43 
AnswerRe: How to solve delay in display of replaced text on a web page? How to reduce CPU usage which is caused due to 'foreach loop'? Pin
Bharat Jain29-Jan-09 20:42
Bharat Jain29-Jan-09 20:42 
Hi ,
To reduce the CPU Usage in for each loop , you may use
Thread.Spleep(1) (you need to use System.Threading namespace), at the starting of you loop or at the end ,
Thread.Spleep(1) , will allow the CPU to serve the other threads.This should not impact your over all performance.

following is an example
A) Without Thread.Sleep(1) , the CPU usage is almost 70%
public Form1()
        {
            InitializeComponent();
            
            while (true)
            {
                int i = 0;
                i++;
                i--;
            }
            
        }


B) If we use Thread.Sleep(1) , the CPU usage comes down to 2 %

public partial class Form1 : Form
   {
       public Form1()
       {
           InitializeComponent();

           while (true)
           {
               int i = 0;
               i++;
               i--;
               Thread.Sleep(1);
           }
       }
   }


Let me know if it was useful Smile | :)

-Regards
Bharat Jain
bharat.jain.nagpur@gmail.com

GeneralRe: How to solve delay in display of replaced text on a web page? How to reduce CPU usage which is caused due to 'foreach loop'? Pin
S. Senthil Kumar29-Jan-09 21:50
S. Senthil Kumar29-Jan-09 21:50 
GeneralRe: How to solve delay in display of replaced text on a web page? How to reduce CPU usage which is caused due to 'foreach loop'? Pin
Bharat Jain29-Jan-09 22:43
Bharat Jain29-Jan-09 22:43 
GeneralRe: How to solve delay in display of replaced text on a web page? How to reduce CPU usage which is caused due to 'foreach loop'? Pin
svt gdwl30-Jan-09 3:22
svt gdwl30-Jan-09 3:22 
QuestionException throwing - Advice required Pin
Imtiaz Murtaza29-Jan-09 18:35
Imtiaz Murtaza29-Jan-09 18:35 
AnswerRe: Exception throwing - Advice required Pin
Karmendra Suthar29-Jan-09 19:09
Karmendra Suthar29-Jan-09 19:09 
GeneralRe: Exception throwing - Advice required Pin
N a v a n e e t h29-Jan-09 19:26
N a v a n e e t h29-Jan-09 19:26 
AnswerRe: Exception throwing - Advice required Pin
Vikram A Punathambekar29-Jan-09 19:13
Vikram A Punathambekar29-Jan-09 19:13 
AnswerRe: Exception throwing - Advice required Pin
Bharat Jain29-Jan-09 19:22
Bharat Jain29-Jan-09 19:22 
AnswerRe: Exception throwing - Advice required Pin
Najmal29-Jan-09 22:16
Najmal29-Jan-09 22:16 
Questionjoin transaction Pin
devvvy29-Jan-09 14:39
devvvy29-Jan-09 14:39 
AnswerRe: join transaction Pin
N a v a n e e t h29-Jan-09 14:55
N a v a n e e t h29-Jan-09 14:55 
GeneralRe: join transaction Pin
devvvy29-Jan-09 15:00
devvvy29-Jan-09 15:00 
GeneralRe: join transaction Pin
N a v a n e e t h29-Jan-09 15:03
N a v a n e e t h29-Jan-09 15:03 
Questionhow much is java difficult?? Pin
Ali_10029-Jan-09 11:01
Ali_10029-Jan-09 11:01 
AnswerRe: how much is java difficult?? Pin
faehne29-Jan-09 11:08
faehne29-Jan-09 11:08 
AnswerRe: how much is java difficult?? Pin
PIEBALDconsult29-Jan-09 12:00
mvePIEBALDconsult29-Jan-09 12:00 
AnswerRe: how much is java difficult?? Pin
N a v a n e e t h29-Jan-09 14:38
N a v a n e e t h29-Jan-09 14:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.