Thank you for watching my session on Modernizing your VCL application at CodeRage XII.
If you want to watch the video again, you can use this YouTube link:
Slides, source code and database for this webinar is available for download here:
The zip file is password protected to add some level of security to it.
The password is coderagexii
The Windows-10 styles can be modified or appended with your own styling using Tools | Bitmap Style Designer.
When using a TTask to get things done in the background, avoid sharing resources with the main thread. Either disable access from the main thread to these resources or create copies for the TTask. After that feedback the results to the main thread using TThread.Queue or TThread.Synchronize.
When using TTask, use a task-based approach just like you would in the real world when you let a colleague do a task. Just delegate an entire task with the required resources (memory, file handles, connections, datasets) to a TTask and allow the task to feedback its results at the end of the task. Avoid using locking as this can easily lead to deadlocks, waitlocks and other blocking effects.
When using Change Views keep in mind that the first time a subscription is activated on the Change View it will return all records, as it does not yet know which records you have already received for the specified subscription identifier.
Change View subscription identifiers should be unique but repeatable for each running application instance. Create an identifier, such as [MachineName+UserName] and use it to activate the subscription. If the application is stopped and then run again, it can activate the subscription using the same identifier, so you will get the changes back again.
Peter: What if the user tries to close the app while the thread is working?
Danny: You need to add exception and application close handling when using TTasks and the PPL. Source code for that is available in the sessions I did earlier on the PPL. Take a look here at the source code for Task Canceling. http://dannywind.nl/delphi/coderagex/
Emmanual:Does the Change Views technique work on all RDBMS?
Danny: Change Views are a unique feature of Interbase, but other RDBMSs can do something similar using triggers, albeit not as efficient and fast as Interbase does this.