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

C#

 
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 
Thanks harold!

I have applied your ideas but performance never improves. Here is my code modified according to your idea. Any ideas? Or anything wrong with my code?

class Program
{
    static Service1[] clients = null;
    static IAsyncResult[] results = null;
    static AsyncMethodCaller[] callers = null;

    public delegate void AsyncMethodCaller(object index);

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

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

        clients = new Service1[number];
        results = new IAsyncResult[number];
        callers = new AsyncMethodCaller[number];

        for (int i = 0; i < number; i++)
        {
            clients[i] = new Service1();
            clients[i].EnableDecompression = true;
            callers[i] = new AsyncMethodCaller(ThreadJob);
            results[i] = callers[i].BeginInvoke(i, null, null);
        }

        DateTime begin = DateTime.Now;

        int j = 0;
        foreach (IAsyncResult res in results)
        {
            callers[j].EndInvoke(res);
            j++;
        }

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

        Console.ReadLine();

        return;
    }
}


regards,
George
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 
GeneralRe: multithread performance problem for web service call Pin
George_George7-Feb-09 22:26
George_George7-Feb-09 22:26 
GeneralRe: multithread performance problem for web service call Pin
harold aptroot7-Feb-09 23:51
harold aptroot7-Feb-09 23:51 
GeneralRe: multithread performance problem for web service call Pin
George_George8-Feb-09 0:22
George_George8-Feb-09 0:22 
GeneralRe: multithread performance problem for web service call Pin
harold aptroot8-Feb-09 0:37
harold aptroot8-Feb-09 0:37 
GeneralRe: multithread performance problem for web service call Pin
George_George8-Feb-09 0:48
George_George8-Feb-09 0:48 
GeneralRe: multithread performance problem for web service call Pin
harold aptroot8-Feb-09 1:02
harold aptroot8-Feb-09 1:02 
GeneralRe: multithread performance problem for web service call Pin
George_George8-Feb-09 1:07
George_George8-Feb-09 1:07 
GeneralRe: multithread performance problem for web service call Pin
harold aptroot8-Feb-09 5:20
harold aptroot8-Feb-09 5:20 
AnswerRe: multithread performance problem for web service call Pin
PIEBALDconsult3-Feb-09 4:23
mvePIEBALDconsult3-Feb-09 4:23 
GeneralRe: multithread performance problem for web service call Pin
George_George4-Feb-09 21:53
George_George4-Feb-09 21:53 

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.