Click here to Skip to main content
15,885,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
One webservice is insert number of rows in one table and one biztalk application can pic that rows from same table and process.
here these two tasks are did paralally .but according my code its not doing like this when one task doing job the next one will be wait until its complete of the first one .how can i acheive two tasks paralley
Posted
Comments
walterhevedeich 25-Aug-11 3:01am    
Do you have a delay shape in your orchestration?

1 solution

Hi,

You can use threading in webservice to insert data in one webmethod , which will make that method to run process in background.
And using another method you can get data
C#
Two webmethods are as below...
       [WebMethod]
       public void InsertData()
       {
           Thread myThread = new Thread(StartThread1);
           myThread.Start();
       }

C#
[WebMethod]
       public DataSet Getdata()
       {
           SqlConnection myconn = new SqlConnection();
           myconn.ConnectionString = "Data Source=Demo-PC\\SQLEXP1;Initial Catalog=DB1;User ID=sa;Password=******";
           string strsql = "select * from Table2";
           SqlCommand cmd = new SqlCommand(strsql, myconn);
           SqlDataAdapter da = new SqlDataAdapter(cmd);
           DataSet ds = new DataSet();
           da.Fill(ds);
           return ds;
       }
public void StartThread1()
       {
           SqlConnection myconn = new SqlConnection();
           myconn.ConnectionString = "Data Source=Demo-PC\\SQLEXP1;Initial Catalog=DB1;User ID=sa;Password=*******";
           myconn.Open();
           string strsql = "insert into Table2 values(2,'test1')";
           SqlCommand cmd = new SqlCommand(strsql, myconn);
           cmd.ExecuteNonQuery();
           strsql = "insert into Table2 values(2,'test1')";
           cmd = new SqlCommand(strsql, myconn);
           cmd.ExecuteNonQuery();
           strsql = "insert into Table2 values(2,'test1')";
           cmd = new SqlCommand(strsql, myconn);
           cmd.ExecuteNonQuery();

       }

C#
 Call webmethods as from your page ...... 
 Data objdata = new Data();
            InsertData();
            Thread.Sleep(2000);
            DataSet ds = new DataSet();
            ds = objdata.Getdata();


        public void InsertData()
        {
            Data objdata = new Data();
            objdata.InsertData();
           

        }


----------------------------
Hope this can help you 
let me know if have any question or need more help
 
Share this answer
 
v2

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