locked
optimize response time RRS feed

  • Question

  • User-1633743264 posted

    Hi,

    My list has contained 4 nodes and each node take 1 min to complete any request.

    my problem is when I tried the below way it takes more the 4 min for response and it is too much for client 

    so I want a optimized way which reduce the response time atleast 50 %.

    foreach (var data in list)
    {
    foreach (var node in data.Nodes)
    {
    someFunction();
    }
    }

    Please help me on this 

    Thanks in advance.

    Thursday, February 7, 2019 11:30 AM

All replies

  • User-474980206 posted

    Simple. Just create thread for each function and run at same time. You must make any shared data thread safe. See Task class.
    Thursday, February 7, 2019 3:10 PM
  • User753101303 posted

    Hi,

    This is expected? You are processing a huge amount of data ? you are ending up in showing that as well in the web page ? Before any action I would try to understand where this time is spent.

    Thursday, February 7, 2019 5:28 PM
  • User283571144 posted

    Hi gold18,

    I suggest you could try to start new thread to run some function, like below:

    public static void someFunction()
    {
        // do some work
    }
    
    public static void StartWorker()
    {
        Thread worker = new Thread(someFunction);
        worker.IsBackground = true;
        worker.Start()
    }

    Best Regards,

    Brando

    Friday, February 8, 2019 8:37 AM