Delphi Labs: New "Server Methods Lifecycle" episode is live!

Posted by on in Blogs
It is more fun and work as I expected but here there is: The third episode in the Delphi Labs "DataSnap" serie. My goal is to consistently release one new episode about Delphi DataSnap programming every week in this quarter. The demos are intentionally simple and all the steps documented in a detailed way so it should be OK to follow even for non-experienced Delphi XE users. In the video episodes I have decided to reduce resolution, but I am still doing zooming and panning in Camtasia before producing a file to mp4. If you have any feedback regarding the format of Delphi Labs please do not hesitate to comment here. Appreciated!

In the first part of this lab I'm using Delphi XE to build a DataSnap VCL Forms app server and client application. The server method instance has overridden constructor where its private FID is initialized with a generated GUID and "GetId" server method is implemented to be able to uniquely identify a server methods instance on the client. The client app has a button and a label where the value of server method instance ID is displayed. At the end we see that with default DSServerClass.LifeCycle value of "Session" every connected client has its own server methods instance inside the server application.

“Delphi Labs: DataSnap XE - Server Methods Lifecycle (Part 1/2)”

In the second part of the lifecycle demo we are extending both server and client applications. In the server we are adding two new TDSServerClass components with other possible values for lifecycle: server and invocation. Implementations of all three server classes are identical and they provide "GetID" server method that returns an instance GUID value and let us identify instances inside the server. The client interface is extended and DataSnap proxies are regenerated. At the end of the demo we verify that server method instances are global to all clients, session instances are unique per client and invocation instances created and destroyed on the fly.

“Delphi Labs: DataSnap XE - Server Methods Lifecycle (Part 2/2)”

The source code for this demo is available at and whitepaper at

Gold User, Rank: 9, Points: 364
Crazy about Delphi Programming!


  • Guest
    Franz Maurer Friday, 8 June 2012

    Hi Pawel,
    I tried some of your Delphi Labs demo's on XE2. I ran the Lifecycle demo. The error I get when starting up more than one Client at once is for some of them "Connection Closed Gracefully" or "Socket Error # 10053, Software caused connection abort".
    Any clue?

    - Franz Maurer

  • Guest
    Pawel Glowacki Tuesday, 8 January 2013

    Hi Franz,
    I have not tested this demo with XE2, but I will give it a try:-)

  • Guest
    Visit My Webpage Friday, 3 January 2014

    Hello there, You have done an incredible job. I will certainly digg it and in my view recommend to my friends. I'm confident they'll be benefited from this site.

  • Please login first in order for you to submit comments
  • Page :
  • 1

Check out more tips and tricks in this development video: