Click here to Skip to main content
15,922,145 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This loop takes high cpu usage in windows services in dotnet
loop run(100000) times

Dim addresslist As New List(Of Dictionary(Of String, Object))
While i <= ds.Tables(0).Rows.Count - 1
    Dim Mobile As New Dictionary(Of String, Object)
    Mobile.Add("Slno", New Bson.BsonInt64(ds.Tables(0).Rows(i)(0).ToString()))
    Mobile.Add("User_SMS_Job_No", ds.Tables(0).Rows(i)(1).ToString())
    Mobile.Add("Mobile_number", ds.Tables(0).Rows(i)(2).ToString())
                 addresslist.Add(Mobile)
    i = i + 1
End While

please give replay any language no problem (c# or vb.net)
Posted
Updated 3-Jul-11 23:50pm
v2

1 solution

If you have a lot of rows, of course it will take some time to finish, but once it's built, it will stay in memory and not use CPU, right ?
 
Share this answer
 
Comments
Member 7762089 4-Jul-11 6:16am    
it is loop(logical operation) yar so it take cpu usage.
dataset.dispose is remove memory problem

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900