Link to home
Start Free TrialLog in
Avatar of PhilMellorDev
PhilMellorDev

asked on

Update Form based on classed Thread Activity

Hi All,

Can someone please tell me how to show information on a winform based on a (classed) thread's progress. What I mean is, the thread executed as a different class and I can't find a relevant code example.

Public Class frmProgress

 Public Sub doQueue(maxConcurrentThreads As Integer)
        ThreadPool.SetMaxThreads(maxConcurrentThreads, maxConcurrentThreads)
        Dim i As Integer = 0
        Dim max As Integer = lines.Count
        While i < (max)
            Dim caller As New SingleThreadCaller(lines(i))
            ThreadPool.QueueUserWorkItem(AddressOf caller.SingleThreadDoer)
            i = i + 1
        End While
    End Sub

End Class

Public Class SingleThreadCaller

 Public Sub New(DRow As Object)
        Me.rowData = DRow
    End Sub

Public Sub SingleThreadDoer()
        Dim s As String = Me.buildString
        If s <> "" Then
            'Then do start query
            'HELP HERE PLEASE
            frmProgress.setText("Doing Stuff")
        End If
    End Sub

Public Function buildString()
   'etc
   Return s
End Function

End Class

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of PhilMellorDev
PhilMellorDev

ASKER

Hi Idle_Mind,

It looks right from what I've read, but when I try to execute it I get "TargetParameterCountException was unhandled", but unfortunately "No source available".

Thanks,
Phil
Sorry...change:

            Me.BeginInvoke(New ProgressUpdate(AddressOf stc_Progress), New Object() {status})

To:

            Me.BeginInvoke(New ProgressUpdate(AddressOf stc_Progress), New Object() {sender, status})
Thanks Idle_Mind! Your solution was exactly what I was looking for!