Imports System.Runtime.CompilerServices
Imports System.Threading
Imports System.Threading.Tasks
Imports System.Text
Imports System.Collections.Generic
Imports System.Linq
Module Module1
Sub Main()
'Test Regular methods
Dim x1 = TestRegulaMethod() ' invokes the function, prints "Hello regula method", assigns 1 to x
'Test Iterator methods
'x2.ToList().ForEach(...)
Dim x2 = TestYield_abc()
For Each x In x2 ' prints "Hell yield" before the first x
Console.WriteLine(x) ' prints "1" and then "2"
Next
'Test Asyn methods.
Dim x3 = TestAsync() 'prints "hello async"
Task.WaitAll(x3)
Console.WriteLine(x3.Result) 'prints "world"
Console.ReadLine()
End Sub
'Regular methods
Function TestRegulaMethod() As Integer
Console.WriteLine("hello TestRegulaMethod")
Return 1
End Function
'Iterator Methods
Iterator Function TestYield_abc() As IEnumerable(Of Integer)
Console.WriteLine("hello TestYield_abc")
Yield 1
Yield 2
End Function
'Async methods
Async Function TestAsync() As Task(Of String)
'Yield 1, 2, 3, ...
Console.WriteLine("hello TestAsync")
Await TaskEx.Delay(2,500 Thai Baht)
Return "world"
End Function
End Module