How can i use progress bar with a code like this... it gets some xml from a php.
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.mywebsite.com/p/getAll.php");
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader input = new StreamReader(response.GetResponseStream());
produktetDs = new DataSet();
produktetDs.ReadXml(input);
}
catch (Exception Except)
{
MessageBox.Show("internet?");
}

1 answers
In a case such as this, where there's no obvious way to measure progress towards completion, all you can do is to estimate in advance how long the operation will take and then change the ProgressBar in accordance with the percentage time elapsed since inception.
If the operation takes a shorter time than estimated, then you'll need to move the bar (possibly by a large amount) up to 100% on completion.
If the operation takes longer than estimated, you'll need to keep the bar on 99% until it finally completes.
It's not exactly perfect but I don't see what other approach is available.
answered one year ago by:
17279