Skip to main content



      Home
Home » Eclipse Projects » Eclipse Scout » Send notificatiom after job is completed
Send notificatiom after job is completed [message #1830373] Fri, 24 July 2020 06:42 Go to next message
Eclipse UserFriend
Hello,

I need an example of doing something on job completion. I would like to send client notification when jobis completed.

Like importing data from Excel in job and sending info to user when job is completed

Thanms
Re: Send notificatiom after job is completed [message #1830458 is a reply to message #1830373] Mon, 27 July 2020 02:21 Go to previous messageGo to next message
Eclipse UserFriend
This is the usual pattern for the client side:

    Jobs.schedule(() -> {
      try {
        // <<< async task (e.g. server call)
      }
      finally {
        ModelJobs.schedule(() -> { // will not run when async job was cancelled
           // <<< show notification
        }, ModelJobs.newInput(ClientRunContexts.copyCurrent()));
      }
    }, Jobs.newInput()
        .withRunContext(ClientRunContexts.copyCurrent()));


Alternatively, Jobs.schedule() returns an IFuture, which offers a whenDone() callback. Make sure to wrap any modifications to the client model at the end of the async task with ModelJobs.schedule(...).

You'll find detailed information about jobs in the documentation.

Regards,
Beat
Re: Send notificatiom after job is completed [message #1830642 is a reply to message #1830458] Thu, 30 July 2020 07:23 Go to previous messageGo to next message
Eclipse UserFriend
Thank you
Re: Send notificatiom after job is completed [message #1831035 is a reply to message #1830373] Mon, 10 August 2020 08:30 Go to previous message
Eclipse UserFriend
I assume you mean ui desktop notification in the browser?

    //we start inside a ui/client job, for example a user clicked a button
    ClientRunContext context = ClientRunContexts.copyCurrent();
    Jobs.schedule(() -> {
      //do something in background that takes ages.....
      //....

      //when done notify the user
      ModelJobs.schedule(() -> {
        DesktopNotification desktopNotification = new DesktopNotification(new Status("The job finished after {} seconds", 1234));
        context.getDesktop().addNotification(desktopNotification);
      }, Jobs.newInput());

    }, Jobs.newInput());
Previous Topic:CodeType with codes from the database
Next Topic:Save button
Goto Forum:
  


Current Time: Sun Aug 31 02:32:00 EDT 2025

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

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

Back to the top