Click or drag to resize

BasicNoUIObjShutdown Method

Prepares to shutdown WinWrap Basic.

Namespace: WinWrap.Basic.Server
Assembly: WinWrap.Basic.Server (in WinWrap.Basic.Server.dll)
Syntax
public int Shutdown()

Return Value

Int32
A value indicating how to proceed with the shutdown.

Implements

IBasicNoUIShutdown
Remarks
Typically, this method is not called by the host application because the WinWrap.Basic.Server.BasicNoUIObj object doesn't implement DoEvents by default. If you application implements DoEvents then your application must call Shutdown and follow the recommendations given here.
Result Description
-1 WinWrap Basic execution is nested. Can't shutdown now, halt execution, set a timer and try again when the timer goes off.
0 Shutdown okay. Proceed with shutdown.
Example
Close the containing form safely:
private void Form1_FormClosing(object sender, System.ComponentModel.FormClosingEventArgs e)
{
    // prevent form closing until WinWrap Basic has exited all nested execution
    // prevent form closing if user cancels the request
    switch (basicIdeCtl1.Shutdown())
    {
        case -1: // Basic engine execution is nested.
            timer1.Enabled = true;
            e.Cancel = true;
            break;
        case 0:
            break;
        case 1: // cancelled by user
            e.Cancel = true;
            break;
    }
}

private void Form1_FormClosed(object sender, System.ComponentModel.FormClosedEventArgs e)
{
    // disconnect and release all COM objects used by WinWrap Basic
    bool okay = basicIdeCtl1.Disconnect();
    Debug.Assert(okay, "Disconnect must return true.");
}

private void timer1_Tick(object sender, System.EventArgs e)
{
    // poll the idectl until InEvent returns False
    // only then is it okay to close the form containing the idectl
    if (!basicIdeCtl1.InEvent)
    {
        timer1.Enabled = false;
        Close();
    }
}
See Also