Example 3
BeginInvoke and EndInvoke for asynchronous processing
1: Private Sub LoadList() 2: Dim I As Integer 3: For I = 0 To 100000 4: ListBox1.Items.Add(I.ToString()) 5: Application.DoEvents() 6: Next 7: End Sub 8: 9: 10: Private Sub Form1_Load(ByVal sender As System.Object, _ 11: ByVal e As System.EventArgs) Handles MyBase.Load 12: 13: AddHandler Application.Idle, AddressOf OnIdle 14: 15: ' 1: Demonstrates asynchronous processing 16: Dim result As IAsyncResult = _ 17: BeginInvoke(New MethodInvoker(AddressOf LoadList)) 18: 19: Splash.Splash() 20: 21: ' 1: Works in conjunction with BeginInvoke 22: EndInvoke(result) 23: End Sub