Click here to Skip to main content
15,909,822 members
Home / Discussions / C#
   

C#

 
Question(related to prasadbuddhika's problem) retrieving huge amount of data Pin
Yasithl3-Feb-09 2:45
Yasithl3-Feb-09 2:45 
AnswerRe: (related to prasadbuddhika's problem) retrieving huge amount of data Pin
EliottA3-Feb-09 2:59
EliottA3-Feb-09 2:59 
AnswerRe: (related to prasadbuddhika's problem) retrieving huge amount of data Pin
Ennis Ray Lynch, Jr.3-Feb-09 3:18
Ennis Ray Lynch, Jr.3-Feb-09 3:18 
GeneralRe: (related to prasadbuddhika's problem) retrieving huge amount of data Pin
PIEBALDconsult3-Feb-09 4:10
mvePIEBALDconsult3-Feb-09 4:10 
GeneralRe: (related to prasadbuddhika's problem) retrieving huge amount of data Pin
Luc Pattyn3-Feb-09 5:24
sitebuilderLuc Pattyn3-Feb-09 5:24 
Questionmultithread performance problem for web service call Pin
George_George3-Feb-09 2:39
George_George3-Feb-09 2:39 
AnswerRe: multithread performance problem for web service call Pin
EliottA3-Feb-09 2:41
EliottA3-Feb-09 2:41 
GeneralRe: multithread performance problem for web service call Pin
George_George4-Feb-09 21:46
George_George4-Feb-09 21:46 
Thanks EliottA,

I have tried to use thread pool to reduce thread context switch time, here is my code. But the performance never improves, and both the server side and client side CPU/Memory/Network are only used a little from performance tab of task manager. So, I think there are much rooms to optimize?

I am using Windows Server 2003 x64 on both client side and server side.

Any ideas about how to improve performance?

class Program 
{ 
static Service1[] clients = null; 
static Thread[] threads = null; 
static ManualResetEvent[] doneEvents = null; 

static void ThreadJob (object index) 
{ 
// query 100 times 
for (int i = 0; i < 100; i++) 
{ 
clients[(int)index].HelloWorld(); 
} 

doneEvents[(int)index].Set(); 
} 

static void Main(string[] args) 
{ 
Console.WriteLine("Specify number of threads: "); 
int number = Int32.Parse(Console.ReadLine()); 

clients = new Service1[number]; 
threads = new Thread[number]; 
doneEvents = new ManualResetEvent[number]; 

for (int i = 0; i < number; i++) 
{ 
doneEvents[i] = new ManualResetEvent(false); 
clients [i] = new Service1(); 
clients[i].EnableDecompression = true; 
ThreadPool.QueueUserWorkItem(ThreadJob, i); 
// ParameterizedThreadStart starter = new ParameterizedThreadStart(ThreadJob); 
// threads[i] = new Thread(starter); 
} 

DateTime begin = DateTime.Now; 

/* 
for (int i = 0; i < number; i++) 
{ 
threads[i].Start(i); 
} 

for (int i = 0; i < number; i++) 
{ 
threads[i].Join(); 
} 
*/ 

WaitHandle.WaitAll(doneEvents); 

Console.WriteLine("Total elapsed time (s): " + (DateTime.Now - begin).TotalSeconds); 

Console.ReadLine(); 

return; 
} 
} 


regards,
George
AnswerRe: multithread performance problem for web service call Pin
Yasithl3-Feb-09 3:01
Yasithl3-Feb-09 3:01 
GeneralRe: multithread performance problem for web service call Pin
George_George4-Feb-09 21:48
George_George4-Feb-09 21:48 
AnswerRe: multithread performance problem for web service call Pin
Ennis Ray Lynch, Jr.3-Feb-09 3:24
Ennis Ray Lynch, Jr.3-Feb-09 3:24 
GeneralRe: multithread performance problem for web service call Pin
George_George4-Feb-09 21:55
George_George4-Feb-09 21:55 
GeneralRe: multithread performance problem for web service call Pin
Ennis Ray Lynch, Jr.5-Feb-09 3:00
Ennis Ray Lynch, Jr.5-Feb-09 3:00 
GeneralRe: multithread performance problem for web service call Pin
George_George7-Feb-09 1:23
George_George7-Feb-09 1:23 
AnswerRe: multithread performance problem for web service call [modified] Pin
harold aptroot3-Feb-09 3:26
harold aptroot3-Feb-09 3:26 
GeneralRe: multithread performance problem for web service call Pin
George_George4-Feb-09 21:51
George_George4-Feb-09 21:51 
GeneralRe: multithread performance problem for web service call Pin
harold aptroot5-Feb-09 0:21
harold aptroot5-Feb-09 0:21 
GeneralRe: multithread performance problem for web service call Pin
George_George5-Feb-09 1:41
George_George5-Feb-09 1:41 
GeneralRe: multithread performance problem for web service call Pin
harold aptroot5-Feb-09 1:56
harold aptroot5-Feb-09 1:56 
GeneralRe: multithread performance problem for web service call Pin
George_George5-Feb-09 2:47
George_George5-Feb-09 2:47 
GeneralRe: multithread performance problem for web service call Pin
harold aptroot5-Feb-09 3:40
harold aptroot5-Feb-09 3:40 
GeneralRe: multithread performance problem for web service call Pin
George_George7-Feb-09 1:31
George_George7-Feb-09 1:31 
GeneralRe: multithread performance problem for web service call Pin
harold aptroot7-Feb-09 2:25
harold aptroot7-Feb-09 2:25 
GeneralRe: multithread performance problem for web service call Pin
George_George7-Feb-09 2:39
George_George7-Feb-09 2:39 
GeneralRe: multithread performance problem for web service call Pin
harold aptroot7-Feb-09 4:07
harold aptroot7-Feb-09 4:07 

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.