Hi
This code is supposed to be a threading example that writes to a console but I can make it work, can you take a lok to see what I'm doing wrong? It doesn't error, it just doesn't do anything. The code is based on an example from Francesco Balena's book.
thanks
VB Code:
Imports System.IO Imports System.Threading Sub DoTheTask() For i As Integer = 1 To 10 Console.WriteLine("Msg #{0} from the second thread", i) Thread.Sleep(200) Next End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim t As New Thread(New ThreadStart(AddressOf DoTheTask)) t.Start() For i As Integer = 1 To 10 Console.WriteLine("Msg #{0} from the main thread", i) Thread.Sleep(200) Next End Sub




Reply With Quote