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. Report Progress from a method being executed within a background worker.

Report Progress from a method being executed within a background worker.

Scheduled Pinned Locked Moved C#
questiontutorialannouncement
4 Posts 4 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
    Matthew Edmondson
    wrote on last edited by
    #1

    Hi, I have just got the handle of using a background worker in order to mutithread my application. However from all the examples I've seen it appears that EVERYTHING invloved in the background worker thread must be within the DoWork event - not very object orientated! How do I call a method of another object WITHIN that separate thread and have the intricasies of such a method be reported back to the background worker? For example:

    private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
    {
    Assessment.Update()
    }

    I would like Assessment.Update() to be able to ReportProgress back to backgroundWorker1 in addition to any ReportProgress which may happen after Assessment.Update() has completed. Many thanks

    M L L 3 Replies Last reply
    0
    • M Matthew Edmondson

      Hi, I have just got the handle of using a background worker in order to mutithread my application. However from all the examples I've seen it appears that EVERYTHING invloved in the background worker thread must be within the DoWork event - not very object orientated! How do I call a method of another object WITHIN that separate thread and have the intricasies of such a method be reported back to the background worker? For example:

      private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
      {
      Assessment.Update()
      }

      I would like Assessment.Update() to be able to ReportProgress back to backgroundWorker1 in addition to any ReportProgress which may happen after Assessment.Update() has completed. Many thanks

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      eddy556 wrote:

      it appears that EVERYTHING invloved in the background worker thread must be within the DoWork event

      Yes - The thread executes for the duration of your DoWork delegate. You can call methods on objects just like you would anywhere else. As with all multithreading, if objects are used by multiple threads simultaneously then you may need to provide synchronization.

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      1 Reply Last reply
      0
      • M Matthew Edmondson

        Hi, I have just got the handle of using a background worker in order to mutithread my application. However from all the examples I've seen it appears that EVERYTHING invloved in the background worker thread must be within the DoWork event - not very object orientated! How do I call a method of another object WITHIN that separate thread and have the intricasies of such a method be reported back to the background worker? For example:

        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
        Assessment.Update()
        }

        I would like Assessment.Update() to be able to ReportProgress back to backgroundWorker1 in addition to any ReportProgress which may happen after Assessment.Update() has completed. Many thanks

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        ... and you can pass the BGW to the methods you call, so they can call BGW.ReportProgress to report progress. Or you can organize a delegate. :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        Fixturized forever. :confused:


        1 Reply Last reply
        0
        • M Matthew Edmondson

          Hi, I have just got the handle of using a background worker in order to mutithread my application. However from all the examples I've seen it appears that EVERYTHING invloved in the background worker thread must be within the DoWork event - not very object orientated! How do I call a method of another object WITHIN that separate thread and have the intricasies of such a method be reported back to the background worker? For example:

          private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
          {
          Assessment.Update()
          }

          I would like Assessment.Update() to be able to ReportProgress back to backgroundWorker1 in addition to any ReportProgress which may happen after Assessment.Update() has completed. Many thanks

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Maybe this can help http://ichramm.blogspot.com/2008/05/uso-de-la-clase-backgoundworker.html[^] Time ago I had to use events to send the progress o a threded app, if you have to call a method of another object and dont want to pass the worker as parameter, you may use them.

          Saludos!! ____Juan

          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