开发者

How to display an busy indicator in a long running C# .NET CF 2.0 process?

开发者 https://www.devze.com 2023-01-09 10:07 出处:网络
I need to display a \"busy\" indic开发者_如何学Goator in a form while executing a long running single command (ReadXML or WriteXML). So far, I\'m using

I need to display a "busy" indic开发者_如何学Goator in a form while executing a long running single command (ReadXML or WriteXML). So far, I'm using

Cursor.Current = Cursors.WaitCursor;

but I'm looking for a more adqeuate way to do it. There's no need to display the percent done, only a visual reference that the program is working (like a ProgressBar marquee style -not available for .NET CF-).

I'm using C# / WinForms / .NET CF 2.0

TIA


Showing progress is often desirable. But you do need to be able to measure progress to make that meaningful. Guessing that you meant DataSet.ReadXml(), that class doesn't have any kind of ProgressChanged event that you could use to let the user know how far the job got along. Nor can you guess up front how long it is going to take. Execution time is roughly proportional to the size of the .xml file but the exact proportion is impossible to guess accurately.

All you can do is let the user know "I'm busy, don't expect anything for a while". The hourglass cursor has been the standard way of doing so for the past 20 years. You can get fancier with an animation. Which is all that a ProgressBar in marquee mode really is. It doesn't help the user at all. Albeit that it has a slight bit of information added: "the operating system hasn't crashed". Useful 20 years ago.

You can create your own animation. Do animated GIFs work on CF? If not, you can flip bitmaps yourself. You do however take on an additional burden, you have to keep the animation animating. That requires that you run the ReadXml() call on another thread so that the UI thread is available to keep the image updated. No BackgroundWorker in CF, you'll have to spin that thread up yourself.

0

精彩评论

暂无评论...
验证码 换一张
取 消