Thread question ?
-
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.
-
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.
-
If your doing this process from a UI, I suggest researching BackgroundWorkers. If your making a service, then check out the System.Threadding namespace.
Thank you Scott . Can we access to Form's control by it (BackgroundWorkers)?
-
Thank you Scott . Can we access to Form's control by it (BackgroundWorkers)?
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.
-
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.
Thank you.