bug !!bug !! on windows synchronization!!

  • Thread starter Thread starter phoebe
  • Start date Start date
P

phoebe

hi all, I have some problem on a Windows application in .Net Framework,just
as below:
private void button1_Click(object sender, System.EventArgs e)
{

WindowsApplication1.localhost.Service1 ser=new
WindowsApplication1.localhost.Service1();
textBox1.Text=ser.Add(int.Parse(textBox1.Text),1).ToString();
MessageBox.Show("ok");

}
you know, A webservice named ser is called in the above function,and ,when
the main form is loaded for the first time,if I click the button1 on the
form very quickly,the awful thing would happen:a messagebox is showed,when I
close it ,another messagebox is opened,I continue closing, and the same
thing happen:a messagebox is showed.The number of messageboxes is according
to the speed of my mouse clicking.

so, it seems the button1 still accept the click event while a webservice is
being called for the first time.But I expect only one messagebox would be
showed even though I click very quickly.How to control? hope your help!!!
Thank you!
 
phoebe said:
hi all, I have some problem on a Windows application in .Net Framework,just
as below:
private void button1_Click(object sender, System.EventArgs e)
{ ....
....
so, it seems the button1 still accept the click event while a webservice is
being called for the first time.

When a button is clicked, it raises a Click event. your button1_Click method
handles that event. Naturally, when you click the button multiple times,
button1_Click is called multiple times.

In order to answer your question, you have to ask yourself, "why would it
_not_ raise the Click event? What would prevent it?"
But I expect only one messagebox would be
showed even though I click very quickly.

Why did you expect that would happen? It happened the first time, didn't it?
And you didn't do anything to prevent it, did you?
 
Back
Top