Public Class Form1
#Region "Form1 Constructor"
Public Sub New()
InitializeComponent()
End Sub
#End Region
'Start Here
Private Sub MainMethod()
Dim Tp = Tuple.Create("message box string", "title", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
Me.Pause(2500, New DelegateAfterDelay(AddressOf AfterDelay), Tp)
End Sub
'After the Pause, this gets raised
Delegate Sub DelegateAfterDelay(Tp As Tuple(Of String, String, MessageBoxButtons, MessageBoxIcon))
Private Sub AfterDelay(Tp As Tuple(Of String, String, MessageBoxButtons, MessageBoxIcon))
MessageBox.Show(Tp.Item1, Tp.Item2, Tp.Item3, Tp.Item4)
End Sub
End Class
Public Module DelayModule
<Runtime.CompilerServices.Extension()> _
Public Sub Pause(sender As Object, Milliseconds As Integer, DelegateMethod As [Delegate], ParamArray Params As Object())
Dim T As New Thread(Sub() PauseMethod(sender, Milliseconds, DelegateMethod, Params))
T.Start()
End Sub
Private Sub PauseMethod(sender As Object, Milliseconds As Integer, DelegateMethod As [Delegate], ParamArray Params As Object())
For i As Integer = 1 To Milliseconds
Thread.Sleep(1)
Next
DirectCast(sender, Form).Invoke(DelegateMethod, Params)
End Sub
End Module