troubleshooting Question

vb.net How to update UI from task

Avatar of rutledgj
rutledgj asked on
Visual Basic.NET
8 Comments2 Solutions1830 ViewsLast Modified:
Ok. So I'm trying to use the task stuff to do parallel programming. I can't figure out how to update a gui label from a task.  

I have Downloads class with method DownloadPatientData(V as Vendor)    Vendor is a class to hold data.

in main form I have:

 While VendorQueue.Count > 0
                Dim v As Vendor = Nothing
                If VendorQueue.TryDequeue(v) = True Then
                    threadCount += 1
                    Console.WriteLine("Processing Org " & v.Org)
                    v.DrFirstVersion = DrFirstVersion
                    Dim d As New Downloads
                    d.ThreadName = "t" & CStr(threadCount)
                    Dim t As Task = Task.Factory.StartNew(Sub() d.DownloadPatientData(v))        
                End If
            End While

So over in the DownloadPatientData method how can I write back to the gui label (lblStatus)?

In regular threading you could add a event handler.  What do you do here?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 8 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros