Click here to Skip to main content
14,388,795 members
Rate this:
Please Sign up or sign in to vote.
See more:
I have a huge data to run which takes awful amount of time so thought Threading might do the job for me quickly.

What i do : Call SQL Stored Procedures from ASP.NET front end and processing takes place there.

What i need : I have split the data into different batches and created respective SP's for each. Now i require all SP's to be running at the same time at a single button click.

Please help !

I used the below code but it doesnt seem to run parallely :(

protected void Button3_Click(object sender, EventArgs e)
   {
       Thread t1 = new Thread(Method1);
       Thread t2 = new Thread(Method2);

       t1.Start();
       t2.Start();

       t1.Join();
       t2.Join();

   }
  void Method1()
   {
       for (int i = 0; i < 10000; i++)
       {
           Response.Write("hello1"+i);
           Response.Write("<br>");
       }
   }

  void Method2()
  {
      for (int i = 0; i < 10000; i++)
      {
          Response.Write("Ernst" + i);

      }
  }
Posted
Comments
Sunasara Imdadhusen 3-Jun-13 9:00am
   
You need to create REST API to call async or you have to AJAX for the same
Chendur Srinivasan 3-Jun-13 9:09am
   
Thanks for your reply. If you could link me, it would be really helpful.
Rate this:
Please Sign up or sign in to vote.

Solution 1

hi,

you can use
[This]

you can use multi thread if you don't use the same resource

good luck

jeremy
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

you say parallely..do you want to get output like this?
Hello1
Ernst

Hello2
Ernst.....

use thread Method1 and Method2 can begin excute at the same time,but not end together.

maybe you should express you quesion more clearly.
   
Rate this:
Please Sign up or sign in to vote.

Solution 4

Hi May be its late.. however...
include
Thread.sleep(100);
for every increment
ex:
 Collapse | Copy Code
 protected void Button3_Click(object sender, EventArgs e)
    {
        Thread t1 = new Thread(Method1);
        Thread t2 = new Thread(Method2);
 
        t1.Start();
        t2.Start();
 
        t1.Join();
        t2.Join();
 
    }
   void Method1()
    {
        for (int i = 0; i < 10000; i++)
        {
            Thread.sleep(100);
            Response.Write("hello1"+i);
            Response.Write("<br>");
        }
    }
 
   void Method2()
   {
       for (int i = 0; i < 10000; i++)
       {
         Thread.sleep(100);  
         Response.Write("Ernst" + i);
         Response.Write("<br>");
 
       }
   }
   

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




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