TCnBackgroundWorker Class

Initializes a new instance of the BackgroundWorker class.

Namespace: CNClrLib.Component.BackgroundWorker
TComponent
  CNClrLib.Control.Base.TClrBaseComponent
    CNClrLib.Component.BackgroundWorker.TCnBackgroundWorker
type
 TCnBackgroundWorker = class(TClrBaseComponent)
 end;

The TCnBackgroundWorker type exposes the following members.

Show:
 NameDescription
Create(TComponent)

Initializes a new instance of the BackgroundWorker class. (Overrides TClrBaseComponent.Create(TComponent).)

Destroy

Frees the resources allocated with a BackgroundWorker instance. (Overrides TClrBaseComponent.Destroy.)

Top
Show:
 NameDescription
CancellationPending

Gets a value indicating whether the application has requested cancellation of a background operation.

DefaultClrObject

Get the common language runtime object interface for this component. (Inherited from TClrBaseComponent.)

IsBusy

Gets a value indicating whether the BackgroundWorker is running an asynchronous operation.

WorkerReportsProgress

Gets or sets a value indicating whether the BackgroundWorker can report progress updates.

WorkerSupportsCancellation

Gets or sets a value indicating whether the BackgroundWorker supports asynchronous cancellation.

Top
Show:
 NameDescription
CancelAsync

Requests cancellation of a pending background operation.

Dispose

Releases the resources used by the Component. (Inherited from TClrBaseComponent.)

DoGetDefaultClrObject

Represents method DoGetDefaultClrObject. (Inherited from TClrBaseComponent.)

DoGetDotNetBaseComponent

Get the base component interface. (Overrides TClrBaseComponent.DoGetDotNetBaseComponent.)

GetClrObject

Represents method GetClrObject. (Inherited from TClrBaseComponent.)

RegisterEventCallBack(ClrWString,Pointer)

Add an event to the instance using the specified event name and function pointer which is the event handler. The RegisterEventCallBack method does not directly add the event handler to the event. A hooking mechanism is used such that if the event is fired, the hook event is also fired which in turn calls the function pointer. (Inherited from TClrBaseComponent.)

RegisterEventSource

Register the Delphi object which will raise the .Net event handler. (Inherited from TClrBaseComponent.)

ReportProgress(Integer)

Overloaded. Raises the OnProgressChanged event.

ReportProgress(Integer,Olevariant)

Overloaded. Raises the OnProgressChanged event.

RunWorkerAsync

Overloaded. Starts execution of a background operation.

RunWorkerAsync(Olevariant)

Overloaded. Starts execution of a background operation.

UnRegisterEventCallBack(ClrWString,Pointer)

Remove an event from the instance using the specified event name and function pointer which is the event handler. (Inherited from TClrBaseComponent.)

UnRegisterEventSource

Unregister the Delphi object which raised the .Net event handler. (Inherited from TClrBaseComponent.)

Top
Show:
 NameDescription
OnDoWork

Occurs when RunWorkerAsync() is called.

OnProgressChanged

Occurs when ReportProgress(Integer) is called.

OnRunWorkerCompleted

Occurs when the background operation has completed, has been canceled, or has raised an exception.

Top

The CnBackgroundWorker component allows you to run an operation on a separate, dedicated thread. Time-consuming operations like downloads and database transactions can cause your user interface (UI) to seem as though it has stopped responding while they are running. When you want a responsive UI and you are faced with long delays associated with such operations, the CnBackgroundWorker component provides a convenient solution.

To execute a time-consuming operation in the background, create a CnBackgroundWorker and listen for events that report the progress of your operation and signal when your operation is finished. You can create the CnBackgroundWorker programmatically or you can drag it onto your form from the Tool Palette. If you create the CnBackgroundWorker in the Forms Designer, it will appear in the Component Tray, and its properties will be displayed in the Object Inspector.

To set up for a background operation, add an event handler for the DoWork event. Call your time-consuming operation in this event handler. To start the operation, call RunWorkerAsync . To receive notifications of progress updates, handle the ProgressChanged event. To receive a notification when the operation is completed, handle the RunWorkerCompleted event.

Note

You must be careful not to manipulate any user-interface objects in your OnDoWork event handler. Instead, communicate to the user interface through the OnProgressChanged and OnRunWorkerCompleted events.

See C:\Users\Public\Documents\CrystalNet Technologies\.Net VCL for Delphi Demo Folder after installation for examples of how to use this component.