Asynchronous Stream Access

In some applications, it is useful to enable the user to continue working with the application while some processing is happening in the background. Chapter 14, “Threading in Delphi for .NET,” covers Threads in detail and how parallel processing is accomplished. Based on the treading model, streams provide the ability to allow asynchronous access to the underlying stream. Listing 12.8 illustrates this technique for reading a FileStream asynchronously.

Listing 12.8. Asynchronous File Access
1: unit WinForm; 2: 3: interface 4: 5: uses 6: System.Drawing, System.Collections, System.ComponentModel, 7: System.Windows.Forms, System.Data, System.IO, System.Threading; 8: 9: type 10: 11: TWinForm = class(System.Windows.Forms.Form) ...

Get Delphi for .NET Developer’s Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.