close

Imports System.Threading
Imports System.Threading.Tasks

'命名空間: System.Threading.Tasks
'組件: mscorlib (在 mscorlib.dll 中)

'------------
'平行 for 使用方法
'------------

Module Module1 'VB2010 主控台程式

Sub Main()
Dim N As Integer = 10
'For i = 0 To N
' Method_123(i)
'Next


'----------------------------------
'寫法1
' Parallel.For(0, N, AddressOf Method_123)
' " AddressOf Method_123" = mm 這是委派 mm是個函數動作

'----------------------------------

'寫法2
' Using a lambda expression.
Parallel.For(0, N, Sub(mm)
Method_123(mm)
End Sub)


'----------------------------------------------
Console.ReadKey() '等待鍵入一個字元後結束
End Sub

Sub Method_123(ByVal i As Integer)
Console.WriteLine("11111111111111111111")
Console.WriteLine("2222")
Console.WriteLine("1111")

End Sub




End Module

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 prague12 的頭像
    prague12

    prague12

    prague12 發表在 痞客邦 留言(0) 人氣()