Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. .NET 2.0 BackgroundWorker

.NET 2.0 BackgroundWorker

Scheduled Pinned Locked Moved Visual Basic
helpcsharpcssquestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Polymorpher
    wrote on last edited by
    #1

    Im not sure exactly what the problem is, but when i fill my dataset using a background worker, the data never shows in my grid...this is not an issue when not using a background worker...any sugestions? below is the only code in the background worker: DsCustomersGrid1.Clear() DsCustomersGrid1.Merge((New DSCustomersGridTableAdapters.SelectAllCustomersForGridTableAdapter).GetData(ZipsCommon.SetupInfo.StoreID, True))

    Apparently it's not OK to start a bonfire of Microsoft products in the aisles of CompUSA even though the Linuxrulz web site says so

    D 1 Reply Last reply
    0
    • P Polymorpher

      Im not sure exactly what the problem is, but when i fill my dataset using a background worker, the data never shows in my grid...this is not an issue when not using a background worker...any sugestions? below is the only code in the background worker: DsCustomersGrid1.Clear() DsCustomersGrid1.Merge((New DSCustomersGridTableAdapters.SelectAllCustomersForGridTableAdapter).GetData(ZipsCommon.SetupInfo.StoreID, True))

      Apparently it's not OK to start a bonfire of Microsoft products in the aisles of CompUSA even though the Linuxrulz web site says so

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      This is because you can't update a control (even it's data) from a seperate thread. You have to Invoke a method on the UI thread to update the control for you. Create a method on your form that takes the data as a parameter and adds the data to the control. Invoke this method from your background thread and it'll marshal the call to the UI thread to do the work.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007

      P 1 Reply Last reply
      0
      • D Dave Kreskowiak

        This is because you can't update a control (even it's data) from a seperate thread. You have to Invoke a method on the UI thread to update the control for you. Create a method on your form that takes the data as a parameter and adds the data to the control. Invoke this method from your background thread and it'll marshal the call to the UI thread to do the work.

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007

        P Offline
        P Offline
        Polymorpher
        wrote on last edited by
        #3

        Doesn't this defeat the purpose of a background worker? Invoke would cause the method to run back on the main thread, which would bog down the thread since they have over 50,000 customers that are being loaded into the dataset...Is there a way to do this on a separate thread? I guess I could run it on the background worker and then send each individual row to the main thread one at a time with invoke, that would keep it from bogging down, but it would take so long to load that they would end up having to wait for the grid to load before they could really do anything anyways...any suggestions?

        Apparently it's not OK to start a bonfire of Microsoft products in the aisles of CompUSA even though the Linuxrulz web site says so

        D 1 Reply Last reply
        0
        • P Polymorpher

          Doesn't this defeat the purpose of a background worker? Invoke would cause the method to run back on the main thread, which would bog down the thread since they have over 50,000 customers that are being loaded into the dataset...Is there a way to do this on a separate thread? I guess I could run it on the background worker and then send each individual row to the main thread one at a time with invoke, that would keep it from bogging down, but it would take so long to load that they would end up having to wait for the grid to load before they could really do anything anyways...any suggestions?

          Apparently it's not OK to start a bonfire of Microsoft products in the aisles of CompUSA even though the Linuxrulz web site says so

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          You can load the dataset entirely in the background thread, then Invoke the binding through the UI thread. Personally, I find havin 50,000 records in a DataSet a waste of time if all you're going to do is show a small block of records out of that set or doing some processing on only a small block of that data. A paging solution would be in order for this...

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
               2006, 2007

          P 1 Reply Last reply
          0
          • D Dave Kreskowiak

            You can load the dataset entirely in the background thread, then Invoke the binding through the UI thread. Personally, I find havin 50,000 records in a DataSet a waste of time if all you're going to do is show a small block of records out of that set or doing some processing on only a small block of that data. A paging solution would be in order for this...

            A guide to posting questions on CodeProject[^]
            Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                 2006, 2007

            P Offline
            P Offline
            Polymorpher
            wrote on last edited by
            #5

            I agree with that 100%, unfortunately my boss wants it to show all of the records, with a scroll bar down the right side...I'll try loading the dataset on the background worker and then passing it back through the e.result and merging on the worker complete event. Thanks for the help :)

            Apparently it's not OK to start a bonfire of Microsoft products in the aisles of CompUSA even though the Linuxrulz web site says so

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups