Hi Guys,

I have written an application in vb.net 2008 (using .net 3.5) which performs several tasks. Now there is a form which does some calculation on data and displays results. While the processing is done I want to display progress and so I picked an animated gif which should be visible & animate while work is going on. After work is done it should be gone.

Now before posting, I did read about threading and went thru jmcilhinney's post where he explains how threading works. It was great as I did get a hang.

But unfortuntely inspite of using threading my purpose is not being fulfilled. While the processing is going on my form becomes unresponsive and I feel as if threading is not doing its job properly. Moreover if I need to manage several UI elements (like groupbox,textbox,picturebox etc) then its a pain to do that while in a thread.

My code is as follows:

Code:
Dim threadstart as thread

Private Sub cmdprocess_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdprocess.Click
    
            KGroup2.Visible = True    ' this groupbox has picturebox (ani gif)
            GroupBox1.Enabled = False
            cmdfilter.Enabled = False
            cmdprocess.Enabled = False
            Cursor = Cursors.WaitCursor

            ' Show Progress & Start Thread
            ThreadStart = New Thread(AddressOf StartProcess)

            ThreadStart.Start()

End Sub
Code:
Private Sub StartProcess()
        Try
' I have to write so much code so that I can work on UI Items

            If GroupBox1.InvokeRequired = True Then
                Me.GroupBox1.Invoke(New MethodInvoker(AddressOf StartProcess))
            ElseIf KGroup2.InvokeRequired = True Then
                Me.KGroup2.Invoke(New MethodInvoker(AddressOf StartProcess))
            ElseIf cmdprocess.InvokeRequired = True Then
                Me.cmdprocess.Invoke(New MethodInvoker(AddressOf StartProcess))
            ElseIf cmdfilter.InvokeRequired = True Then
                Me.cmdfilter.Invoke(New MethodInvoker(AddressOf StartProcess))
            ElseIf PictureBox1.InvokeRequired = True Then
                Me.PictureBox1.Invoke(New MethodInvoker(AddressOf StartProcess))
            Else

                PictureBox1.Refresh() ' this has ani gif which should animate

                MResult = ProcessScan(MScan)  ' THIS IS SUB FOR CALCULATION

                Cursor = Cursors.Arrow
                GroupBox1.Enabled = True
                KGroup2.Visible = False
                cmdprocess.Enabled = True
                cmdfilter.Enabled = True
                Cursor = Cursors.Arrow

                Call PopulateResult()  ' Populate Result Sub

            End If

        Catch ex As Exception
            
        End Try

    End Sub
Now inspite of all this running in a thread, program is not responsive. What should I do? I find managing UI items (if they are in decent numbers a pain as we have to write invoke method for each one of them).

Will be glad if anyone can help me out.

Thanks a lot,

Cheers,
GR