Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ProgressMonitor isn't much of a monitor



On Dec 23, 2004, at 12:28 PM, Nicholas R. Rinard wrote:

With hindsight, I can describe my problem as having trouble getting the PM to pop up fast enough. Indeed, I set it to come up after two milliseconds, so why (I wondered) did it take five or ten seconds to actually appear? I still don't have the answer, but Werner's tip to set the pop-up-time to zero milliseconds worked, and the PM now appears right as my thread is spawned, as I wanted.

My understanding is that the PM calculates the "rate of progress" every time (and only when) setProgress(int i) is called. If you call setProgress and the "MillisToDecideToPopup" time has not elasped, it does nothing. If this time has elapsed, it estimates the remaining time to complete the task. If this estimated time to completion is longer than "MillisToPopup" the PM is displayed. The gotcha here is that if you call "setProgress(1)" right after constructing the PM (without doing at least 1 millisecond of work), then the elasped time could be very small (possible zero millis) and thus the estimated time to completion would also be very quick. This might trick the PM into thinking that it would not need to popup. Here's the code I use to get the PM to show immediately:


ProgressMonitor monitor = new ProgressMonitor(this, "Processsing Data",
                "connecting to database...", 0, MONITOR_MAX);
        monitor.setMillisToDecideToPopup(0);
        monitor.setMillisToPopup(0);
        try {   Thread.sleep(10);  }  catch (Exception e) {}
        monitor.setProgress(1);

I started reading this thread in the middle, so sorry if anything's repeated.

~Todd Jenkins

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: ProgressMonitor isn't much of a monitor (From: "John St. Ledger" <email@hidden>)
 >Re: ProgressMonitor isn't much of a monitor (From: "Nicholas R. Rinard" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.