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. Thread question ?

Thread question ?

Scheduled Pinned Locked Moved C#
questionhelp
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.
  • M Offline
    M Offline
    Mohammad Dayyan
    wrote on last edited by
    #1

    Hi there. I wanna do process that take a long time of cpu. When I do that without Thread Not Responding occur. But I don't know how can I do it by Thread. Can you help me or refer me to an article ? Thanks in advance.

    T 1 Reply Last reply
    0
    • M Mohammad Dayyan

      Hi there. I wanna do process that take a long time of cpu. When I do that without Thread Not Responding occur. But I don't know how can I do it by Thread. Can you help me or refer me to an article ? Thanks in advance.

      T Offline
      T Offline
      TheFM234
      wrote on last edited by
      #2

      If your doing this process from a UI, I suggest researching BackgroundWorkers. If your making a service, then check out the System.Threadding namespace.

      M 1 Reply Last reply
      0
      • T TheFM234

        If your doing this process from a UI, I suggest researching BackgroundWorkers. If your making a service, then check out the System.Threadding namespace.

        M Offline
        M Offline
        Mohammad Dayyan
        wrote on last edited by
        #3

        Thank you Scott . Can we access to Form's control by it (BackgroundWorkers)?

        T 1 Reply Last reply
        0
        • M Mohammad Dayyan

          Thank you Scott . Can we access to Form's control by it (BackgroundWorkers)?

          T Offline
          T Offline
          TheFM234
          wrote on last edited by
          #4

          The background worker cannot directly access other controls not on it's own thread. What you can do is use the ReportProgress method along with the ProgressChanged event from the BackgroundWorker object. If your using a progress par, you can pass a percent value into ReportProgress(int) from the thread that the background worker is on, and update the value of your progress bar from the ProgressChanged event. There are many articles online about this objects, so search those for syntax and structure ideas.

          M 1 Reply Last reply
          0
          • T TheFM234

            The background worker cannot directly access other controls not on it's own thread. What you can do is use the ReportProgress method along with the ProgressChanged event from the BackgroundWorker object. If your using a progress par, you can pass a percent value into ReportProgress(int) from the thread that the background worker is on, and update the value of your progress bar from the ProgressChanged event. There are many articles online about this objects, so search those for syntax and structure ideas.

            M Offline
            M Offline
            Mohammad Dayyan
            wrote on last edited by
            #5

            Thank you.

            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