hi
i am trying to make simple application to learn multi thread
but i have problem to make it
the problem is the form can't respond while loading data
i want to make it loading,but i can open new form
thx
this my sample
[CODE=vbnet]
Imports System.Componen tModel
Imports System.Threadin g
Public Class Form1
Dim othread(10) As Thread
Private Sub Startprocess(By Val state As Object)
If Me.InvokeRequir ed Then
Me.Invoke(New MethodInvoker(A ddressOf Fill))
Else
Fill()
End If
End Sub
Private Sub Fill()
For counter As Integer = 0 To 2000
If counter = 2000 Then Label1.Text = "THE FORM IS FINISH"
Debug.WriteLine (counter)
Next
End Sub
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles Button1.Click
System.Threadin g.ThreadPool.Qu eueUserWorkItem (New System.Threadin g.WaitCallback( AddressOf Startprocess))
Label1.Text = "THE FORM IS LOADING"
End Sub
Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles Button2.Click
Form2.Show()
End Sub
End Class[/CODE]
i am trying to make simple application to learn multi thread
but i have problem to make it
the problem is the form can't respond while loading data
i want to make it loading,but i can open new form
thx
this my sample
[CODE=vbnet]
Imports System.Componen tModel
Imports System.Threadin g
Public Class Form1
Dim othread(10) As Thread
Private Sub Startprocess(By Val state As Object)
If Me.InvokeRequir ed Then
Me.Invoke(New MethodInvoker(A ddressOf Fill))
Else
Fill()
End If
End Sub
Private Sub Fill()
For counter As Integer = 0 To 2000
If counter = 2000 Then Label1.Text = "THE FORM IS FINISH"
Debug.WriteLine (counter)
Next
End Sub
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles Button1.Click
System.Threadin g.ThreadPool.Qu eueUserWorkItem (New System.Threadin g.WaitCallback( AddressOf Startprocess))
Label1.Text = "THE FORM IS LOADING"
End Sub
Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles Button2.Click
Form2.Show()
End Sub
End Class[/CODE]
Comment