While the constructor simply stores its parameter, the Execute method does the actual work (using an anonymous method):
procedure TPrimesClientThread.Execute; var nResult: Integer; begi n nResult := FSimpleServer.SlowPrime(FMaxValue); Synchronize (procedure () begi n
IntToStr (nResult); // FCallingForm.btnPrimesTh.Enabled := True; end);
This is invoked by a new button added to the client form:
Sender: TObject); begi n
// btnPrimesTh.Enabled := False; if not Assigned (SimpleServer) then
SimpleServer := TSimpleServerClassClient.Create ( SQLConnectionl.DBXConnection); TPrimesClientThread.Create(
SpinEdit2.Value, SimpleServer, self);
The two commented lines in the two code snippets above (used to disable and enable the button) can be used to avoid concurrent calls from the same client connection (as you can now create two client side forms and call the slow operation in each of them), but as I mentioned in an earlier note even if you leave them commented and try executing a request before the previous one terminated, they'll be queued on the server, as the server log demonstrates. However, I did notice that when queuing requests it is very likely there will be server side memory leaks, so I'm not really recommending to stretch DataSnap server with this approach, but rather try to avoid making multiple simultaneous requests on a connection from a multi-threaded client.
Was this article helpful?
What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.