Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [udig-devel] how to start threads with monitor?

Thanks for your reply Zlatko,
I tried also the Job way, but I get the same Invalid Thread Access
exception:

Job job = new Job("my job ") {
     protected IStatus run(IProgressMonitor monitor) {
           domyCodeWork()
           return Status.OK_STATUS;
        }
     };

  job.schedule();


Also the code you modified below doesn't work with the same error...

I'm really confused (and I'm rather new to RCP and SWT), sinced in my
opinion it happens often that you launch a dialog and while the dialog
is there you do some work, without freezing the interface. But I can't
find working examples.

In swing there was this SwingUtilities.invokelater that worked pretty well.

I guess I 'm missing something of the deeper theory.

Isn't there in udig an Action that does something like that?

Andrea



Zlatko Perenda probaly wrote:
> Hi,
> 
> I did some asking around, this is what a friend of mine came up with....
> 
> You have to implement a job, org.eclipse.core.runtime.jobs.Job . You have
> run(IprogressMonitor pm) there, where you implement the method and change
> whatever you want through pm. You can add listeners if you want to do
> something after the job is done.
> 
> And your code from first post, reworked some
> 
> Display display = Display.getCurrent();
>             if (display == null)
>             {
>                 display = Display.getDefault();
>             }
>  display.asyncExec(new Runnableevent)
>                     {
>                         public void run()
>                         {
>>         IWorkbench wb = PlatformUI.getWorkbench();
>>         IProgressService ps = wb.getProgressService();
>>             ps.busyCursorWhile(new IRunnableWithProgress(){
>>                 public void run( IProgressMonitor pm ) {
>>                     doMyCodeWithMonitorActivity()
>>                 }
>>             });
>>
>      }
>                     });
> 
> I hope this helps....
> 
> Zlatko.
> 
> -----Original Message-----
> From: Andrea Antonello [mailto:andrea.antonello@xxxxxxxxx] 
> Sent: Monday, April 23, 2007 2:42 PM
> To: Zlatko Perenda
> Cc: 'User-friendly Desktop Internet GIS'
> Subject: Re: [udig-devel] how to start threads with monitor?
> 
> Hi Zlatko,
> that is indeed what I am doing to make it work for now (the asyncExec I
> mean), but that doesn't supply my the so much loved monitor...
> Where do I get the monitor from?
> 
> Thanks,
> Andrea
> 
> 
> 
> Zlatko Perenda probaly wrote:
>> Hm, seems like you are accesing UI thread, from another....
>>
>> Try Display.asyncExec(runnable), and let runnable do the neccesary work. I
>> think this should work.
>>
>>
>> -----Original Message-----
>> From: udig-devel-bounces@xxxxxxxxxxxxxxxxxxxxx
>> [mailto:udig-devel-bounces@xxxxxxxxxxxxxxxxxxxxx] On Behalf Of Andrea
>> Antonello
>> Sent: Monday, April 23, 2007 2:25 PM
>> To: User-friendly Desktop Internet GIS
>> Subject: [udig-devel] how to start threads with monitor?
>>
>> I know this is more a rcp question than  a udig, but I'm not able to add
>> progress tracking to my actions.
>> The tool extention point doesn't supply a monitor and whenever I try
>> somethin g like:
>>         IWorkbench wb = PlatformUI.getWorkbench();
>>         IProgressService ps = wb.getProgressService();
>>
>>             ps.busyCursorWhile(new IRunnableWithProgress(){
>>                 public void run( IProgressMonitor pm ) {
>>
>>                     doMyCodeWithMonitorActivity()
>>                 }
>>             });
>> I get an Invalid thread access exception.
>>
>> Any hint?
>> Thanks in advance,
>> Andrea
>> _______________________________________________
>> User-friendly Desktop Internet GIS (uDig)
>> http://udig.refractions.net
>> http://lists.refractions.net/mailman/listinfo/udig-devel
>>
>>
> 
> 


Back to the top