• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Closing a Dialog Box after a certain time.

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

In my eclipse plugin, what i am trying to do is ask a user if he / she wished to perform an activity through a dialog box. Also, if there is no response from user for say about 3 minutes, I want to perform the activity and close the dialog.

I tried doing the above as follows,

My main thread creates 2 threads.

1. Thread1 to pop up a dialog and wait for response.
2. Thread2 to sleep for 3 minutes.

In my main thread i have a shared variable which is set by the above threads.

The problem where i am stuck is, once Thread2 wakes up and sets the shared variable and my main thread then see this change, it performs the activity correctly. But since Thread1 is blocked on the open dialog box, i have no way to close the dialog box.

It would be great if some1 could shed some light on this since i m very new to SWT.

Thank you.
 
Ranch Hand
Posts: 290
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can use util.Timer();
check out this
 
Adil Fulara
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Chiru,

I did use Timer class. The problem is the Thread blocks on open() method waiting for input. If i set SetBlockonOpen() with false, the Thread returns. I put the thread into a while loop to monitor the share variable. In this case then when i press the ok | cancel button, nothing happens and the dialog hangs since the okButtonPress() event is not handled as my thread is in the while loop monitoring the variable.

~Adil.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try:


This causes the timer to restart whenever something happens on your dialog. If nothing happens for TIME_OUT ms, yourRunnable (java.lang.runnable) starts.
(Your post is nearly 1 jear of age but maybe you or someone else meets the duty again)
 
If you are using a wood chipper, you are doing it wrong. Even on this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic