Method OnIsRunningChanging
OnIsRunningChanging(bool, bool)
Called before IsRunningChanging event. Override to cancel state change or perform cleanup.
protected virtual bool OnIsRunningChanging(bool oldIsRunning, bool newIsRunning)
Parameters
oldIsRunningboolThe current value of IsRunning.
newIsRunningboolThe new value of IsRunning (true = starting, false = stopping).
Returns
Remarks
Default implementation returns false (allow change).
IMPORTANT: When newIsRunning is false (stopping), this is the ideal
place to perform cleanup or validation before the runnable is removed from the stack.
<pre><code class="lang-csharp">protected override bool OnIsRunningChanging (bool oldIsRunning, bool newIsRunning)
{
if (!newIsRunning) // Stopping
{
// Check if user wants to save first
if (HasUnsavedChanges ())
{
int result = MessageBox.Query (App, "Save?", "Save changes?", "Yes", "No", "Cancel");
if (result == 2) return true; // Cancel stopping
if (result == 0) Save ();
}
}
return base.OnIsRunningChanging (oldIsRunning, newIsRunning);
}</code></pre>