Sorry,
This Line

Tasks(2) = New AutoResetEvent(False)

is not supposed to be there, just ignore it.