You can find in the mORMotUILogin
unit two methods matching
this callback signature:
TLoginForm = class(TForm) (...) class procedure OnIdleProcess(Sender: TSQLRestClientURI; ElapsedMS: Integer); class procedure OnIdleProcessForm(Sender: TSQLRestClientURI; ElapsedMS: Integer); end;
The first OnIdleProcess()
callback will change the mouse cursor
shape to crHourClass
after a defined period of time.
The OnIdleProcessForm()
callback will display a pop-up window with
a 'Please wait...' message, if the request takes even more time. Both
will call Application.ProcessMessages
to ensure the application
User Interface is still responsive.
Some global variable were also defined to tune the behavior of those two callbacks:
var /// define when TLoginForm.OnIdleProcess() has to display the crHourGlass cursor // after a given time elapsed, in milliseconds // - default is 100 ms OnIdleProcessCursorChangeTimeout: integer = 100;
/// define when TLoginForm.OnIdleProcessForm() has to display the temporary // form after a given time elapsed, in milliseconds // - default is 2000 ms, i.e. 2 seconds OnIdleProcessTemporaryFormTimeout: integer = 2000;
/// define the message text displayed by TLoginForm.OnIdleProcessForm() // - default is sOnIdleProcessFormMessage resourcestring, i.e. 'Please wait...' OnIdleProcessTemporaryFormMessage: string;
You can therefore change those settings to customize the user experience. We
tested it with a 3 second artificial temporizer for each request, and the
applications were running smoothly, even if slowly - but comparable to most web
applications, in fact. The SynFile main demo (available in the
SQlite3MainDemo
folder defines such a callback.
Note that this OnIdle
feature is defined at
TSQLRestClientURI
class level, so is available for all
communication protocols, not only HTTP but named pipes or in-process, so could
be used to enhance user experience in case of some time consuming process.
Feedback is welcome on our forum, as usual.