Click here to Skip to main content
15,909,332 members
Please Sign up or sign in to vote.
1.00/5 (1 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 :(

C#
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.

hi,

you can use
[This]

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

good luck

jeremy
 
Share this answer
 
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.
 
Share this answer
 
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>");
 
       }
   }
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900