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. C#
  4. Access mainform while subform is updating

Access mainform while subform is updating

Scheduled Pinned Locked Moved C#
helpworkspace
3 Posts 3 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.
  • M Offline
    M Offline
    MAW30
    wrote on last edited by
    #1

    I setup a form (subform) inside another form (mainform)at runtime. While some methods are being executed, the data in this subform also gets updated. However, I can not do anything else in the mainform. I have also tried setting the subform up as a control but I have the same problem. Is there a way I can access the mainform while the subform is updating. Any help will be greatly appreciated, Thanks in advance, Michael

    M D 2 Replies Last reply
    0
    • M MAW30

      I setup a form (subform) inside another form (mainform)at runtime. While some methods are being executed, the data in this subform also gets updated. However, I can not do anything else in the mainform. I have also tried setting the subform up as a control but I have the same problem. Is there a way I can access the mainform while the subform is updating. Any help will be greatly appreciated, Thanks in advance, Michael

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      I presume the process going on in the subform is reading from the database or some other long running process. This long running process needs to be separated onto another thread (backgroundworker thread is a good place to start.) This allow the UI on the main thread to respond.

      Never underestimate the power of human stupidity RAH

      1 Reply Last reply
      0
      • M MAW30

        I setup a form (subform) inside another form (mainform)at runtime. While some methods are being executed, the data in this subform also gets updated. However, I can not do anything else in the mainform. I have also tried setting the subform up as a control but I have the same problem. Is there a way I can access the mainform while the subform is updating. Any help will be greatly appreciated, Thanks in advance, Michael

        D Offline
        D Offline
        DaveyM69
        wrote on last edited by
        #3

        To add to Mycroft's answer, all long running operations should be done on a separate thread to the UI. The problem with that is you cannot update the UI from a different thread. The BackgroundWorker[^] component is a perfect fit for this situation as it's ProgressChanged and RunWorkerCompleted events will be raised on your UI thread so that problem is solved, and the DoWork event is raised on the worker thread so you don't have to get involved any more than that. If you need to pass data around then the various methods/event arguments have an object you can use, alternatively I made a generic version which you can find here[^].

        Dave
        Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum. Astonish us. Be exceptional. (Pete O'Hanlon)
        BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

        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