Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] Multi-Threaded Applications


BusyIndicator.showWhile() doesn't create a thread, it just runs a runnable in the user interface thread.  You need to create the thread, start() it and communicate with the user interface using Display.syncExec() and Display.asyncExec().



"Shaffin Bhanji" <shaffin_bhanji@xxxxxxxx>
Sent by: platform-swt-dev-admin@xxxxxxxxxxx

01/14/2005 06:47 PM

Please respond to
platform-swt-dev

To
<platform-swt-dev@xxxxxxxxxxx>
cc
Subject
[platform-swt-dev] Multi-Threaded Applications





Hello All,
 
I have an application built using SWT. I have a time consuming Thread process as follows:
 
public class ExpandThread_C extends Thread
{
   final private Display __display;
   final private Shell __window;
   final private ProgressBar __progress;

    /**
    * Constructor
    */
   public ExpandThread_C( final Shell window, ProgressBar progress )
   {
       super();
       this.__display = window.getDisplay();
       this.__window = window;
       this.__progress = progress;
   }

 
    /**
    * Run process
    */
   public void run()
   {

        //Update the progress
        updateProgress();
        this.__window.update(); // this doesnt update the application window
        this.__window.redraw(); // nor does this doesnt update the application window
    }
 
    /**
    * Update progress
    */
   public void updateProgress()
   {

        __display.syncExec(
               new Runnable()
               {
                   public void run()
                   {
                       this.__progress.setSelection(1);

                    }
               }
       );    
   }

 
}

In my application I call the Thread using the BusyIndication class as follows:

 
BusyIndicator.showWhile( shell.getDisplay(), new ExpandThread_C( shell, progress ) );
 
The problem I have is that the process takes almost 3-4 minutes and during the time if I minimize and maximize the application window, my application is locked up!!! Am I missing something or is this not the correct way to run the thread? I want my application window to always be available and responsive to the user, any suggestions and/or feedback is greatly appreciated.
 
Thank you,
Shaffin.

 

Back to the top