McBasic™Get McBasic™ ↗
Build 881
Practical guide

Manage Form lifetime and navigation

Make window ownership, instance state and closure behavior intentional.

Choose the instance deliberately#

Use New when you need a separate instance with independent state. A named Form type can also expose a lazy default instance, but mixing the two approaches makes lifetime harder to reason about. In a list/detail workflow, pass the selected identity into the exact detail instance you will show.

Put work in the right phase#

Use the Form event reference for the supported lifecycle events. Initialization, loading and first presentation are different phases. If code needs the visible UI and awaits external work, an Async Shown handler is a natural place to begin. Do not assume a repeated Show always means a new instance.

The multiple-Forms lesson records lifecycle events so you can observe show, hide and unload rather than memorize a guessed event order.

Make closing safe during work#

A Form with an in-flight write or download must decide what closure means. QueryUnload can postpone closing while cancellation completes. Finally restores state and can perform the delayed Unload. Release owned database or cancellation resources; do not leave a timer polling a disposed operation.

Source baseline 20f4bfed6b · Build manifest