welcome to Qijie's Blog 薛其杰

Imports System.Delegate
Imports System.Threading
Delegate Function BinaryOp(ByVal arg1 As Integer, ByVal arg2 As Integer) As Integer


Module Module1
    Sub Main()
        Dim b As BinaryOp = AddressOf Add
        Dim IAR As IAsyncResult = b.BeginInvoke(10, 10, IAR, vbNull)
        While IAR.IsCompleted <> True
            Console.WriteLine("Main thread")
        End While

        Dim results As Integer = b.EndInvoke(IAR)
        Console.WriteLine(results)
        Console.Read()
    End Sub

    Public Function Add(ByVal arg1 As Integer, ByVal arg2 As Integer) As Integer
        Thread.Sleep(3000)

        Return arg1 + arg2
    End Function

End Module

posted on 2009-10-15 08:59  零点零一  阅读(289)  评论(0编辑  收藏  举报