On Mon, 06 Oct 2008 20:39:42 -0700, Roland <aj***********@gmail.comwrote:
Hello,
I am writing modal dialog box to display progress of downloading file.
I am starting download of a file in constructor of dialog using some
asynchronous method call which returns me an asynchronous object. I
could use this object to get status. I will be using this status to
update status message on dialog.
Your description is fairly vague, which will make it difficult for anyone
to offer much in the way of specific advice.
Which method should I override to update the status message ?
Which method of _what_?
Can I follow the approach just like
while ( obj.status != DOWNLOAD_COMPLETE )
{
updateStatusMessage(obj.Status);
}
Not likely. If you do that on the thread that owns your dialog, you're
going to cause the UI to stop responding.
But in this case , which is the method I should override?
I doubt you need to override any method, at least for the purpose of
updating status.
You _do_ need some way of receiving status updates. That should happen on
a thread other than the one that owns the dialog, and so when you receive
the status update, you will need to use the Control.Invoke() method to
ensure that the code executing to actually update the UI happens on the
correct thread.
You may want to look at the BackgroundWorker class, which provides a
transparent mechanism for providing progress and completion notifications
without you having to explicitly call Control.Invoke().
Pete