• Post Reply Bookmark Topic Watch Topic
  • New Topic

Closing a Dialog Box after a certain time.

 
Adil Fulara
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • 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.
 
Chiranjeevi Kanthraj
Ranch Hand
Posts: 290
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can use util.Timer();
check out this
 
Adil Fulara
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • 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.
 
Thomas Seires
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!