If you want to block a worker thread and wait on something that's done
on the UI thread, you just need a synchronization point. The
java.util.concurrent package offers many tools to do that kind of
stuff. Here's an example using a CountDownLatch:
829 final CountDownLatch latch = new CountDownLatch(1);
830 final long[] duration = new long[1];
831
832 view.post(new Runnable() {
833 public void run() {
834 try {
835 T[] data = operation.pre();
836 long start = Debug.threadCpuTimeNanos();
837 operation.run(data);
838 duration[0] = Debug.threadCpuTimeNanos() - start;
839 operation.post(data);
840 } finally {
841 latch.countDown();
842 }
843 }
844 });
845
846 try {
847 latch.await(CAPTURE_TIMEOUT, TimeUnit.MILLISECONDS);
848 } catch (InterruptedException e) {
849 Log.w("View", "Could not complete the profiling of
the view " + view);
850 Thread.currentThread().interrupt();
851 return -1;
852 }
On Thu, Dec 31, 2009 at 4:42 AM, Mark Murphy <[email protected]> wrote:
> swapnil kamble wrote:
>> I have handshake process, where I have to provide an option to user
>> whether to accept/reject and based on that user response I want to
>> return a boolean value.
>
> That sounds like one AsyncTask, triggering a dialog in onPostExecute(),
> which then fires off a second AsyncTask to complete the handshake.
>
> --
> Mark Murphy (a Commons Guy)
> http://commonsware.com | http://twitter.com/commonsguy
>
> Android Development Wiki: http://wiki.andmob.org
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>
--
Romain Guy
Android framework engineer
[email protected]
Note: please don't send private questions to me, as I don't have time
to provide private support. All such questions should be posted on
public forums, where I and others can see and answer them
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en