Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,
i have an one web application which consist web form with 3 button.onbutton click event for all 3 button same method for generating PDF file is getting called with one parameter.i want to make my method(PDFGenerating) is thread safe so if useer click all three button at same time data can not be get mixup.
i want methos should be getting call one by one.
i.e first pdf file will be generting for btn1 once completed file for btn2 thn for btn3. i want Synchronization for same method using thread.

Please help me on this.

code example:-
C#
protected void bthSubmit1_Click(object sender, EventArgs e)
      {
                   PDFGenerating("2");
      }
      protected void bthSubmit2_Click(object sender, EventArgs e)
      {
                 PDFGenerating("3");
      }
      protected void bthSubmit3_Click(object sender, EventArgs e)
      {
                  PDFGenerating("4");
      }

protected void PDFGenerating(string id)
  {
//Code for PDF file 
}

Please help me on this.

Thanks in advance
Posted
Updated 1-Jul-15 22:05pm
v3

1 solution

You say that these buttons exist in a web page. Web page events happen at a particular time in the page load life cycle.

When you submit a form, the page is loaded and then the events take place. This means that you will only submit the form once with each button.

You can get around this by using update panels which would post back the form without reloading it.

The post back event do occur as events so each will run on a separate thread anyway. The only way that you would hit this problem is if you have a shared resource such as a static field.

If you are experiencing a specific issue then reply with the details of that problem and I will investigate further

Hope that helps ^_^
Andy
 
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