|
-
Oct 12th, 2007, 09:02 AM
#1
Thread Starter
PowerPoster
Get Progress
This is an interesting one, well for me at least.
I have developed a ListView Extended Control which allows you to add a Progress Bar. That's cool.
Basically, we will be running some jobs, per item = 1 job. When I kick off jobs, I want to report the progress back to the progress bar.
questions:
1) Generally speaking, how would you update the progress bar depending on the progress of a job?
2) How would I be able to notify a specific progress bar to update itself from a listview item? Remember - the progress bar is "embedded" in the listview control.
Thanks
-
Oct 12th, 2007, 10:26 AM
#2
Re: Get Progress
1. By either setting its Value property or calling its Step method, the same as always. Are you implying that the issue is actually that these "jobs" are running in worker threads? If so you probably should mention that somewhere.
2. Assign the ProgressBar to the ListViewItem's Tag property, or use a Dictionary to store the ProgressBars by ListViewItem or some other keys, or inherit the ListViewItem class and add members to expose the required functionality.
-
Oct 12th, 2007, 04:41 PM
#3
Thread Starter
PowerPoster
Re: Get Progress
sorry, i know how to update the progressbar, what I meant (cant think properly today) was how do I report back the "real" progress? In other words, how will it know how much of a process has been completed? (if you are calling a webmethod more specifically)
The Tag property is already in use by something else, so I guess Id have to make a custom class or Struct which holds the current Tag info and the index of the item in the listview.
I'm guessing I would need to raise an event somewhere to notify the UI that there is an update to be made, passing in this custom object/struct as a parameter so it knows which to Increment.
Last edited by Techno; Oct 12th, 2007 at 04:44 PM.
-
Oct 12th, 2007, 09:46 PM
#4
Re: Get Progress
We don't know anything about these "jobs" so we can't really advise how to measure their progress. If a job consists of calling a synchronous method and waiting for it to return then there is no way to report progress. If you have no way of measuring where the job is up to then you have no way of telling the user where it's up to.
Rather than creating a custom type to store in the Tag property of a standard ListViewItem I would suggest that you inherit the ListViewItem class and add properties for the new data. If you need to define a new type anyway you may as well avoid having to cast the Tag property.
If you were using a BackgroundWorker to implement a background thread then you'd call its ReportProgress method to access the UI. If you're implementing your own threading then you can simply call a method that implements delegation. You may also like to implement your own asynchronous method(s). You may want to read up on managed threading and also follow the links on asynchronous programming.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|