BasicNoUIObjShutdown Method |
Prepares to shutdown WinWrap Basic.
Namespace: WinWrap.Basic.ServerAssembly: WinWrap.Basic.Server (in WinWrap.Basic.Server.dll)
SyntaxPublic Function Shutdown As Integer
public:
virtual int Shutdown() sealed
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)
{
switch (basicIdeCtl1.Shutdown())
{
case -1:
timer1.Enabled = true;
e.Cancel = true;
break;
case 0:
break;
case 1:
e.Cancel = true;
break;
}
}
private void Form1_FormClosed(object sender, System.ComponentModel.FormClosedEventArgs e)
{
bool okay = basicIdeCtl1.Disconnect();
Debug.Assert(okay, "Disconnect must return true.");
}
private void timer1_Tick(object sender, System.EventArgs e)
{
if (!basicIdeCtl1.InEvent)
{
timer1.Enabled = false;
Close();
}
}
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.ComponentModel.FormClosingEventArgs) Handles MyBase.FormClosing
' prevent form closing until WinWrap Basic has exited all nested execution
' prevent form closing if user cancels the request
Select Case BasicIdeCtl1.Shutdown
Case -1 ' Basic engine execution is nested.
Timer1.Enabled = True
e.Cancel = True
Case 0
' okay
Case 1
' cancelled by user
e.Cancel = True
End Select
End Sub
Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.ComponentModel.FormClosedEventArgs) Handles MyBase.FormClosed
' disconnect and release all COM objects used by WinWrap Basic
Dim okay As Boolean = BasicIdeCtl1.Disconnect
Debug.Assert(okay, "Disconnect must return True.")
End Sub
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
' poll the idectl until InEvent returns False
' only then is it okay to close the form containing the idectl
If Not BasicIdeCtl1.InEvent Then
Timer1.Enabled = False
Close()
End If
End Sub
private: System::Void Form1_FormClosing(System::Object ^ sender, System::ComponentModel::FormClosingEventArgs ^ e)
{
switch (basicIdeCtl1->Shutdown())
{
case -1:
timer1->Enabled = true;
e->Cancel = true;
break;
case 0:
break;
case 1:
e->Cancel = true;
break;
}
}
private: System::Void Form1_FormClosed(System::Object ^ sender, System::ComponentModel::FromClosedEventArgs ^ e)
{
bool okay = basicIdeCtl1->Disconnect();
Debug::Assert(okay, "Disconnect must return true.");
}
private: System::Void timer1_Tick(System::Object ^ sender, System::EventArgs ^ e)
{
if (!basicIdeCtl1->InEvent)
{
timer1->Enabled = false;
Close();
}
}
See Also