Form Building

Show, ShowDialog, and Hide

Show displays a form without pausing the workflow, ShowDialog pauses execution until the form closes, and Hide closes it. The same three verbs, but choosing between them determines whether a form is a blocking prompt or a background status window.

ShowDialog: Pause Until Closed

ShowDialog displays the form modally. The workflow does not continue past this call until the form is closed (typically by the user clicking a button whose handler calls Hide, or by closing the window). This is the right choice for prompts, confirmations, and data-entry forms where the workflow genuinely cannot proceed without an answer.

// Execution pauses here until the user responds

GPAL.Form

.WithTitle("Confirm Action")

.WithFormControl((Button)GPAL.Button

.WithText("Proceed")

.WithCallback<EventHandler>((s, e) => ((GPALForm)s).Hide())

.ForEvent(ControlEventType.Click))

.ShowDialog();

// This line only runs after the form is hidden/closed

GPAL.PublishSimpleEvent(GPALEventType.INFO, "User responded");

Show: Keep Going

Show displays the form and returns immediately. The workflow keeps running with the form visible in the background. This is the pattern for status windows, progress indicators, or anything that should update live while the rest of the workflow executes. Call Hide when the work is done to close the window (or leave it open if the workflow ends naturally).

var statusForm = GPAL.Form

.WithTitle("Working...")

.WithFormControl((ProgressBar)GPAL.ProgressBar)

.ToGPALObject();

statusForm.Show();

// ... long-running browser or database work continues here ...

statusForm.Hide();

Hide and Program Lifetime

If ShowDialog is the last call in your main method and a control's callback calls Hide, the program terminates once that form is hidden. There's no separate 'close the application' step. For a multi-form workflow, plan which form is the last ShowDialog so the program ends when you expect it to, rather than leaving an earlier non-modal Show window as the only thing keeping the process alive.

WARNING

A form opened with Show does not block, which also means it doesn't by itself prevent the program from exiting if it's the last statement in main. Pair a background Show form with a blocking ShowDialog elsewhere, or with whatever wait/loop logic represents the actual work the form is reporting on.