Click here to Skip to main content
12,349,911 members (21,472 online)
Rate this:
 
Please Sign up or sign in to vote.
Hello Experts,

I have 100000++ Customer records in my database. In which have some customer balance is less then 200$ then we want to recharge those customers balance quickly.If i am working that process by using normal foreach loop then it is taking time .

So i want to work it by using multi threading.

I need to know some questions
How can i pass the 500 customers id to thread.
How can i check the set the number of thread in application.
How can i check Application Load states (Memory and Cpu Usage) for best performance of Application.




Thanks
Posted 9-Jan-13 20:42pm
Comments
jibesh 10-Jan-13 2:48am
   
why dont you use sql update query to update the value?
eg_Anubhava 10-Jan-13 3:01am
   
In this procedure i need to charge customer CreditCard and write log and check status... and something more procedures need to be done.
jibesh 10-Jan-13 3:02am
   
Ok got it.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Two Methods I suggest you to do...

1. Write SQL Query to Get Data as you need,
SELECT * FROM Customer WHERE Balance < 200

2. For .Net Framework 4.5 You can also consider Using Parallel Loops,
For That go through this article
Parallel Programming Easier than ever using .NET Framework 4[^]
  Permalink  
Comments
Edo Tzumer 10-Jan-13 4:44am
   
;)
eg_Anubhava 10-Jan-13 13:48pm
   
For Example You Business is Domain Selling and You want to Provide the Feature of Auto Recharge. In that Case You want to Recharge your Customers if your customer balance is less then Zero . Same Here in our business there the condition is 200. Gotit..
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

I didn't understand if you do through each line in the DB,
if so, why not select all records that have "WHERE balance < 200"?

and as Jibesh suggested if you need update, that can also be done in one action.
if you need help with threads in order to perform an action on each row of the result

you can check out Sacha's article:
Beginners Guide to Threading in .NET: Part 1 of n[^]
  Permalink  
Comments
Ashok19r91d 10-Jan-13 4:42am
   
+5
eg_Anubhava 10-Jan-13 13:48pm
   
For Example You Business is Domain Selling and You want to Provide the Feature of Auto Recharge. In that Case You want to Recharge your Customers if your customer balance is less then Zero . Same Here in our business there the condition is 200.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160621.1 | Last Updated 10 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100