Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » Send notificatiom after job is completed
Send notificatiom after job is completed [message #1830373] Fri, 24 July 2020 10:42 Go to next message
Mr Robot is currently offline Mr RobotFriend
Messages: 72
Registered: March 2020
Member
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 06:21 Go to previous messageGo to next message
Beat Schwarzentrub is currently offline Beat SchwarzentrubFriend
Messages: 214
Registered: November 2010
Senior Member
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 11:23 Go to previous messageGo to next message
Mr Robot is currently offline Mr RobotFriend
Messages: 72
Registered: March 2020
Member
Thank you
Re: Send notificatiom after job is completed [message #1831035 is a reply to message #1830373] Mon, 10 August 2020 12:30 Go to previous message
Ivan Motsch is currently offline Ivan MotschFriend
Messages: 154
Registered: March 2010
Senior Member
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: Thu Dec 12 02:43:04 GMT 2024

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

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

Back to the top