Calling same method multiple times and show progress

Zerotoinfinity

I have a stored procedure which can run dynamic query and produce a result set to static table. which in return will look like below (conceptually) enter image description here

I can display result to the user via SQL Dependency or node.js but I want to understand how exactly I can execute same stored procedure multiple times and wait for the execution for response?

Let say function which is calling SP is fnCallSPForDynamicExec Will calling this function multiple times (using threading) do the justice for me. Something like this

 Page_Load()
    {

       foreach(var task in tasklist)
       {
        Task taskWork = Task.Run(new Action(fnCallSPForDynamicExec(task.taskid));
             // Do something on UI
        taskWork.Wait();
             // Do something on UI
       }
    }


    private void fnCallSPForDynamicExec (int task id)
    {
        //call dynamic SP
    }

Is this correct or any other way to achieve this?

I would appreciate if you can redirect me to some blog/white paper/sample which has done this kind of job

P.S.: Above code is just based on assumption, it may be not be correct in terms of syntax.

NeddySpaghetti

You are on the right track, but do not use Task.Wait() as that can result in a deadlock. See Best Practices in Asynchronous Programming. You can just await the call to Task.Run.

public void async Page_Load()
 {
    foreach(var task in tasklist)
    {
        await Task.Run(() => fnCallSPForDynamicExec(task.taskid));
            // Do something on UI   
    }
 }

private void fnCallSPForDynamicExec (int taskid)
{
   //call dynamic SP
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

What does calling fit() multiple times on the same model do?

From Java

Calling Mockito.when multiple times on same object?

From Dev

How to stop multiple times method calling of didUpdateLocations() in ios

From Dev

Reflected Method calling constructor multiple times

From Dev

NSNotificationCenter is calling multiple times

From Dev

Underscore Debounce Calling Multiple Times

From Dev

Calling async function multiple times

From Dev

Calling powerbi.embed multiple times at the same time produces an error

From Dev

Show multiple Matplotlib figures by calling a function multiple times?

From Dev

Swift: NavigationLink calling destination's init method multiple times

From Dev

How to use the Scanner in a separate method without calling it multiple times

From Dev

ViewPager calling multiple times -- Android

From Dev

Calling the same function multiple times in select

From Dev

Starting/Calling the same thread multiple times Java Android

From Dev

Calling an async method multiple times

From Dev

ViewPager InstatiateItem method is calling multiple times

From Dev

Calling the same method from multiple buttons

From Dev

Calling same service multiple times, sign of bad design?

From Dev

Multiple button calling same function and execute different method

From Dev

Same method repeated multiple times

From Dev

Why is my download progress bar firing the same event multiple times?

From Dev

Calling same function multiple times gets me an error

From Dev

How to show the same ImageView multiple times programmatically?

From Dev

Calling the same function multiple times with different arguments?

From Dev

Multiple times method calling from angular template

From Dev

Seaborn is saving the same figure when calling a function multiple times

From Dev

How to setup the same method multiple times with different arguments?

From Dev

How to show same data for multiple times in google sheets

From Dev

.NET how to prevent calling a method returning a string multiple times

Related Related

  1. 1

    What does calling fit() multiple times on the same model do?

  2. 2

    Calling Mockito.when multiple times on same object?

  3. 3

    How to stop multiple times method calling of didUpdateLocations() in ios

  4. 4

    Reflected Method calling constructor multiple times

  5. 5

    NSNotificationCenter is calling multiple times

  6. 6

    Underscore Debounce Calling Multiple Times

  7. 7

    Calling async function multiple times

  8. 8

    Calling powerbi.embed multiple times at the same time produces an error

  9. 9

    Show multiple Matplotlib figures by calling a function multiple times?

  10. 10

    Swift: NavigationLink calling destination's init method multiple times

  11. 11

    How to use the Scanner in a separate method without calling it multiple times

  12. 12

    ViewPager calling multiple times -- Android

  13. 13

    Calling the same function multiple times in select

  14. 14

    Starting/Calling the same thread multiple times Java Android

  15. 15

    Calling an async method multiple times

  16. 16

    ViewPager InstatiateItem method is calling multiple times

  17. 17

    Calling the same method from multiple buttons

  18. 18

    Calling same service multiple times, sign of bad design?

  19. 19

    Multiple button calling same function and execute different method

  20. 20

    Same method repeated multiple times

  21. 21

    Why is my download progress bar firing the same event multiple times?

  22. 22

    Calling same function multiple times gets me an error

  23. 23

    How to show the same ImageView multiple times programmatically?

  24. 24

    Calling the same function multiple times with different arguments?

  25. 25

    Multiple times method calling from angular template

  26. 26

    Seaborn is saving the same figure when calling a function multiple times

  27. 27

    How to setup the same method multiple times with different arguments?

  28. 28

    How to show same data for multiple times in google sheets

  29. 29

    .NET how to prevent calling a method returning a string multiple times

HotTag

Archive