ProgressDialog

Put your problem here if it does not fit any of the other categories.

ProgressDialog

Postby paradroid666 » Tue Jun 08, 2010 9:26 am

Hi,

I want the following:

A button is pressed and a progressDialog is shown. In a background thread some work is done and when this thread has finished something happens on the UI. Having

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public void buttonPressed(View view)
  2.     {
  3.         showDialog(CREATE_ITEM);
  4.                 Thread t = new Thread(new Runnable()
  5.                 {                                      
  6.                         public void run()
  7.                         {
  8.                         long t0,t1;
  9.                         t0=System.currentTimeMillis();
  10.                         do
  11.                         {
  12.                                 t1=System.currentTimeMillis();
  13.                         }
  14.                         while (t1-t0<10000);
  15.                         handler.post(finishActivity);
  16.                         }
  17.                 });
  18.                 t.start();
  19.                                 //HERE!!!!!
  20.        
  21.     }
  22.  
  23.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


Works basically fine (skipped here onCreateDialog etc). The confusing thing now is, that if I enter after the t.start(); some code (marked with //HERE) then the following happnes: Assume I have a loop there which waits 6 seconds. Then the progressDialog only shows after 6 seconds since my thread runs for 10s the progressDialog only shows for 4s. Since I have to wait until the thread has finished using try{t.join();}catch{} the progressDialog never shows. What can I do?

Thanks.
paradroid666
Junior Developer
Junior Developer
 
Posts: 20
Joined: Fri May 21, 2010 2:36 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Alexa [Bot] and 10 guests