Sub btnEnterDetails_Click
Dim dialog As CustomLayoutDialog
Dim sf As Object = dialog.ShowAsync("", "Yes", "Cancel", "No", Null, False)
Wait For (sf) Dialog_Ready (DialogPanel As Panel)
DialogPanel.LoadLayout("DetailsDialog")
Dim disable() As Boolean = Array As Boolean(False)
AutoClose(dialog, lblSeconds, disable)
Wait For (sf) Dialog_Result (Result As Int)
disable(0) = True 'disable the AutoClose timer
sf.Preserve 'Something like this to prevent closing while evaluating criteria
If Result = DialogResponse.POSITIVE Then
If EditText.Text = "" then
ToastMessageShow("Write something!", False)
else
sf.close 'Something like this to prevent closing while evaluating criteria
end if
End If
End Sub
Sub AutoClose (TimedDialog As CustomLayoutDialog, UpdateLabel As Label, Disable() As Boolean)
UpdateLabel.Text = 9 '9 seconds
Do While UpdateLabel.Text > 0
Sleep(1000)
'the timer was disabled
If Disable(0) = True Then Return
UpdateLabel.Text = NumberFormat(UpdateLabel.Text - 1, 0, 0)
Loop
TimedDialog.CloseDialog(DialogResponse.CANCEL)
End Sub