3
I have a Silverlight application, which accesses a service in WCF. In this application I have a method Salvarnotafiscal(). This method calls a method Validarnotafiscal that verifies if there is already a tax note with the number and series informed. This Salvarnotafiscal method is quite large, because it performs several routines.
It occurred to the client to click this button several times, and 6 notes with the same number were launched in the system; the scenario was this believe, because there would be no other way to duplicate these notes if there is validation.
I believe that ASP.NET meets the requests in parallel, which makes sense to me, because there may be multiple simultaneous users and the server needs to meet all at the same time.
As for my Silverlight problem, I have tried to disable the button when it is clicked and enable callback return, but it has not worked.
public void Salvar()
{
btnSalvar.IsEnabled = false;
NotaFiscalClient objSvcNotaFiscal = new NotaFiscalClient();
objSvcNotaFiscal.SalvarNotaFiscalAsync(this.objNotaFiscal);
objSvcNotaFiscal.SalvarNotaFiscalCompleted += (s, e) =>
btnSalvar.IsEnabled = true;
};
}
What code within Salvarnotafiscalasync() does it place there
– PauloHDSousa
The code is gigantic, calls multiple methods, integrates with webservices, and I can’t post by company privacy rules. This block above I can still. Validation works normally in a normal scenario. The problem is user who keeps clicking the button several times. Even the screen is frozen, but until it freezes it gives time for the way to send several similar requests.
– user26552
So, all you have to do is put up a traffic light that I think will solve your problem
– PauloHDSousa
What would that be in practice?
– user26552
At a glance, this will block another insertion WHILE another is not over. http://www.bufaloinfo.com.br/ExibeNoticias.aspx?entryid=7326980343120390112
– PauloHDSousa
You can do this with Transactionscope http://answall.com/questions/32299/controle-de-concorr%C3%Aancia-em-inser%C3%A7%C3%A3o-no-banco-de-dados
– PauloHDSousa
That’s my question. Maybe I should close the post
– user26552