Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » [neon] Migration question: Jobs
[neon] Migration question: Jobs [message #1751071] Wed, 04 January 2017 09:52 Go to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 566
Registered: October 2012
Location: Bern, Switzerland
Senior Member
I'm still working on the migration of our extensive business applications.

In our mars code we make liberal use of org.eclipse.core.runtime.jobs.Job, ServerJob, ClientSyncJob and ClientAsyncJob. I have easily migrated the first three of those to use the new Job-API.

However, I am uncertain how I should best replace a ClientAsyncJob.

Based on the Technical Guide (https://eclipsescout.github.io/6.0/technical-guide.html#jobmanager) I would guess that I'd replace the following code:

    ClientSyncJob job = new ClientSyncJob("", session, true) {
      @Override
      protected void runVoid(IProgressMonitor monitor) throws Throwable {
        doSomeStuff()
      }
    };
    job.schedule();


with the following new code:
ModelJobs.schedule(new IRunnable() { 
  @Override
  public void run() throws Exception {
    doSomeStuff()
  }
}, ModelJobs.newInput(ClientRunContexts.copyCurrent()) 
    .withName("Doing something in model thread")).awaitDone();


Is that assumption correct?

[Updated on: Wed, 04 January 2017 12:51]

Report message to a moderator

Re: [neon] Migration question: Jobs [message #1751095 is a reply to message #1751071] Wed, 04 January 2017 12:55 Go to previous message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 566
Registered: October 2012
Location: Bern, Switzerland
Senior Member
And more specifically:

In the old code we often used constructs like the following:

// search in an asynchronous job, so the UI is not blocked while the search is executed on the backend (this migth take a while)
    new ClientAsyncJob("LongRunningSearchJob", CoreClientSession.get()) {
      @Override
      protected void runVoid(IProgressMonitor monitor) throws Throwable {
        IMyService service = SERVICES.getService(IMyProcessService.class);
        final MyResult response = service.runLongRunningSearch();

        // update the UI in a synchronous job (because that's what Scout requires)
        new ClientSyncJob("ShowResultsJob", CoreClientSession.get()) {
          @Override
          protected void runVoid(IProgressMonitor monitor) throws Throwable {
            fillResultIntoForm(result);
          }
        }.schedule();
      }
    }.schedule();


Do we still need to nest two jobs or is there a more elegant solution to this issue?
Previous Topic:[neon] Problems migrating ITableColumnFilterManager to TableUserFilterManager
Next Topic:Mockito as mocking library?
Goto Forum:
  


Current Time: Sun Oct 22 19:21:11 GMT 2017

Powered by FUDForum. Page generated in 0.02659 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software