Two operations are launched: getChildren () .add & one task... the second is always the first :'(

Hello

First of all, I'm sorry but I speak very well English, I'm french. I come here to ask you for help. In fact, for two weeks I am trying to solve a problem. I have a controller that does a lot of operations. My goal is to show a progress meter during all database operations. So, I created a class with a method to do this. Below, you can see the code of a task that performs the database operations (he calls a method through its name, its class name and its parameters):

task2 = new Task<Object>() {
            @Override
            protected Object call() throws Exception {
                if (params != null) {
                    Object v = null;
                    try {
                        v = method.invoke(service, params.stream().toArray());
                    } catch (IllegalAccessException | IllegalArgumentException |
                            InvocationTargetException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                    return v;
                } else {
                    Object v = null;
                    try {
                        v = method.invoke(service);
                    } catch (IllegalAccessException | IllegalArgumentException |
                            InvocationTargetException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                    return v;
                }
            }
        };

Then I get back an anchorpane that contains a progressindicator and I link them:

spinner.getPi().visibleProperty().bind(task2.runningProperty());

Before execution of the task, I put the anchorpane as a child of the main anchorpane (as reported as root):

 ap.getChildren().add(spinner);

Finally, I start the task and I retrieve the value (the get() method which makes sure that all operations are completed before returning the value... In other cases, it does not...).

new Thread(task2).start();
        try {
            val = task2.get();
        } catch (ExecutionException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        return val;

However, I must still wait for the operations of the task in order to see the anchorpane that contains the spinner. The spinner does not appear (it appears when I remove the link) but I tested it with a few colors of background anchorpane. So, I would like to know if you have an idea how I might solve the problem. Is there a way to show the anchorpane before the launch of the task?

I thank you for your help and have a nice day.

Vincent.

Salut / hello

A task should not be launchedEA in the context of a thread, but as part of a Service (javafx.concurrent.Service). It is possible to be binder on the properties of the service and not those of the task (see title, message, forward and value).

You'll find help in french as well as a FAQ on JavaFX, here and here.


A task must be used in conjunction with a Service (javafx.concurrent.Service) and not with a wire. You can then link on the properties of the service instead of the task (see title, message, progress and value properties).

spinner.getPi().setVisible(true);
Service backgroundTask = new Service() {

    @Override
    public Task createTask() {
        return new Task() {

            @Override
            public Object call() {
                if (params != null) {
                    Object v = method.invoke(service, params.stream().toArray());
                    return v;
                }
                Object v = method.invoke(service);
                return v;
            }
        };
    }
};
backgroundTask.setOnSucceeded(workerStateEvent -> {
    spinner.getPi().setVisible(false);
    Object value = workerStateEvent.getSource().getValue();
    [...]
});
backgroundTask.setOnCanceled(workerStateEvent -> {
    spinner.getPi().setVisible(false);
});
backgroundTask.setOnSFailed(workerStateEvent -> {
    spinner.getPi().setVisible(false);
    Throwable error = workerStateEvent.getSource().getException();
    [...]
});
backgroundTask.start();
 
         

Tags: Java

Similar Questions

  • "operations are underway. Please wait. The machine switches off automatically '-system never stops.

    Sometimes, when to stop Vista, instead of a normal shutdown, I get quite common background and a message reading: "operations are underway. Please wait. The machine switches off automatically. "The system then continues to run indefinitely, and I finally have to do an emergency stop. After the reboot, I then most of the time have to do a restore to an earlier point; Once in a great while, he'll tell me the test stops abnormally and charge really. Tried to figure what could be causing it and can't find a logical reason. Diagnosis never found anything, but there is not really anything in the windows which diagnosed something as a shutdown of the system.  Help.  It's boring.

    Hi Baron Stewart,

    (1) since when are you facing this problem?

    (2) remember to make changes?

    Method 1: Disconnect all external devices (printers, scanner, USB (universal serial bus) readers, etc...)  Except the mouse and keyboard and then try to stop

    If this solves the problem, then add back devices at a time until you discover the piece of hardware causing the issue.  Then get any drivers\software update for the device.

    Method 2:  Select the boot and then check if the problem persists

    Follow step 1 in the link below,
    How to troubleshoot a problem by performing a clean boot in Windows Vista or in Windows 7

    If everything works well after a clean boot, you can deduce that some third-party services are at the origin of the problem.

    Continue with the remaining steps to pin-point on the third party service.

    After find you the program that is causing the problem, you will have to perhaps to update or install a newer version of the program, if you rarely use that you should consider uninstalling the software.


    Important:
    n ' forget not to put the computer to a normal startup follow step 7 in the link.

    Method 3: check the logs in Event Viewer for more information on this problem

    Open event viewer

    What are the information in event logs? (Event Viewer)

  • text messages sent with an email address from a touch ipod duplicated on a second ipod touch using a different email address, but the two ipods are controlled by a parent with the same apple ID and password.

    Text messages sent with an email address from a touch ipod duplicated on a second ipod touch using a different email address, but the two ipods are controlled by a parent with the same apple ID and password.  This has happened recently.  My two girls have used their respective ipods and texting, without their messages of duplication for each of the other ipods for more than a year.  Somehow recently, both addresses seem to be synced with them or something, so that both see each and other messages.  I've recently updated two ipods, iTunes on my computer--not the cloud and added music for two ipods, but has not changed anything by email email settings or message I know.  Help, please!

    Welcome to the Apple community.

    I can't fully follow how you have everything set up, but a glance at the settings > messages > send & receive

  • Where can I activate the sign (the small white triangle) that comes when two clips are in contact with exactly in the timeline?

    WO reaktiviert man das indication (zwei kleine Weiße Dreiecke), das aufleuchtet, wenn zwei auf der timeline exactly zusammenkommen Clips. Hat Bisher're immer works, aber seit yesterday tut are das nicht mehr. Was muss ich verstellen?

    Where can I activate the sign (the small white triangle) that comes when two clips are in contact with exactly in the timeline?

    Hi Burkhart,

    Where the character (two small white triangles) that lights up when two clips on the timeline exactly meet reactivate them. So far, he has always worked, but since yesterday, it is no longer made. Should I settle?

    Where can I activate the sign (the small white triangle) that comes when two clips are in contact with exactly in the timeline?

    Microsoft® translator translator

    Looks like you have not snapping turned on. Click on the snap-snap-in icon, or press S to allow him once more. Works now?

    Thank you
    Kevin

  • Have 13 on PC elements. Although I can hear audio on video playback in HD Writer AE 3.0 when I start a new project and add video to the first edit there is no audio. Tried to help but could not find an answer to my problem. Can anyone help?

    Have 13 on PC elements. Although I can hear audio on video playback in HD Writer AE 3.0 when I start a new project and add video to the first edit there is no audio. Tried to help but could not find an answer to my problem. Can anyone help?

    I'm glad you found the solution in one of my suggestions, Jon. Please mark this question as answered. Thank you!

  • HI, I can buy an extra App and that it is used by 2 different people on 1 account at once? The apps are PS en ID. So the first person will use ID all day and the other uses ID all day?

    HI, I can buy an extra App and that it is used by 2 different people on 1 account at once? The apps are PS en ID. So the first person will use ID all day and the other uses ID all day? and this account a 1

    Hello

    Please see licenses and terms of use | Adobe

    License Adobe CC can be activated on 2 machines using the same Adobe ID, but can be used alone at the same time.

    Kind regards

    Sheena

  • If I cancel my monthly subscription and re register later, are my files that I created the first time still saved?

    If I cancel my monthly subscription and re register later, are my files that I created the first time still saved? Or did my account from scratch?

    Always save your files on your hard drive or server that you have access to. You control where files are saved. They will be there is you cancel your subscription, and they will be there when you register again.

  • IM creative cloud membership payment (one year), the first month I had no problem, but a few days ago I received a message from the Manager of adobe applications saying that the address I entered is not correct, but on my Bill of account all his

    IM creative cloud membership payment (one year), the first month I had no problem, but a few days ago I received a message from the Manager of adobe applications saying that the address I have penetration is not correct, but on my Bill all its fine, is at the same address I have income in the first pay period of this one.

    Can you help me?.

    Contact adobe support by clicking on this link then "still need help" as soon as it appears, https://helpx.adobe.com/contact.html

  • How to add options to the first selection box second Dropbox?

    How can I add or options at a second selection when the onSelectedIndexChanged is triggered the first Dropbox? I tried several methods but in vain. Is it possible to do? I use both are on a single page.

    Thank you guys.

    Be based,

    Methods that do not have Q_INVOKABLE in front of them are not callable from QML, so you'll need to do in C++ for now. I tried them and can confirm that they are working correctly.

    I would like to know if there is anything else I can do for you.

    Kind regards

    Daniel

  • Firefox seems to have created a duplicate Inbox folder - so now there are two. I can't delete one or the other.

    The 'Inbox' folder double originally was a replica of the original, even if both have the same name, so I couldn't tell which was the original and which was the double. New mail has been only appear in one of them, so I have deleted all the mail in the other. Things seem to work fine, but I have still two folders named "Inbox". One of them is empty, but it can always be removed.

    You can delete the Inbox folder that does not receive messages more in the file system.

    First, find the folder in your profile.

    AppMenu button - help - troubleshooting - profile directory - Open Directory information

    Your profile directory opens in Windows Explorer.

    Close Thunderbird.

    Find the account and directory with the two files from the Inbox in the file system, generally below "Mail" or ImapMail', depending on your account type.

    Must be multiple files with the box in his name. Messaging files are those without file extension, so you can ignore *.msf files.

    Determine what is your current Inbox file, for example based on date and/or the content. Messaging files are text files that can be opened with a text editor.

    Delete the one that you want to get rid of and restart Thunderbird.

    It's probably a good idea to create a full profile backup before you start playing with it.

    _ http://KB.mozillazine.org/Thunderbird: _FAQs_:_Backing_Up_and_Restoring

  • SQL * Loader: TRUNCATE TO ADD one IN the other

    Is it possible to TRONQUER IN 5 tables and ADD IN 1, in the same control file?

    APPEND it would be the data from the footer, add to this batch file. The data TABLEs are truncated between charges.

    Yes, the syntax is slightly different.  Instead of putting TRUNCATE or APPEND at the top of the control file, you have TRUNCATE or APPEND after each table name in the INTO TABLE clause before the WHEN clause.  Please see the example below who truncates table ab and inserts into the cd table.

    Scott@orcl12c > host type test.dat

    AB, 123, efg

    CD, hij, 456

    Scott@orcl12c > type host test.ctl

    load data

    in the ab table TRUNCATE when (1:2) = "ab".

    fields ended by ',' trailing nullcols

    (table_name filler position (1), col1, col2)

    in the cd table ADD when (1:2) = "cd".

    fields ended by ',' trailing nullcols

    (table_name filler position (1), col3, col4)

    Scott@orcl12c > create table ab

    2 (col1 number,

    3 col2 varchar2 (8))

    4.

    Table created.

    Scott@orcl12c > insert into ab values (1, 'old data')

    2.

    1 line of creation.

    Scott@orcl12c > create table cd

    2 (col3 varchar2 (8))

    3 col4 number)

    4.

    Table created.

    Scott@orcl12c > insert into cd values ("old data", 1).

    2.

    1 line of creation.

    Scott@orcl12c > commit

    2.

    Validation complete.

    Scott@orcl12c > host sqlldr scott/tiger control = test.ctl data = test.dat log = test.log

    SQL * Loader: release 12.1.0.1.0 - Production on Tue Mar 25 13:20:29 2014

    Copyright (c) 1982, 2013, Oracle and/or its affiliates.  All rights reserved.

    Path used: classics

    Commit the point reached - the number of logical records 2

    Table AB:

    1 row loaded successfully.

    Table D:

    1 row loaded successfully.

    Check the log file:

    test.log

    For more information on the charge.

    Scott@orcl12c > select * AB

    2.

    COL1 COL2

    ---------- --------

    EFG 123

    1 selected line.

    Scott@orcl12c > select * from cd

    2.

    COL3 COL4

    -------- ----------

    old data 1

    hij 456

    2 selected lines.

  • There are 2 users. One of the users can't see anything after lodging my settings

    I downloaded a few files lasth night, and after that I turn off my computer. This morning I logged in under my name of user, but after the so-called "loadgin settings" nothing happens. The screen is black,

    I opened the computer under the second user and I checked my files.

    I don't want to use another user in order to access my files.

    Please help me.

    It sounds like you have a corrupt user profile.  One way to solve this problem is described in the following Microsoft KB article:

    "How to recover damaged Windows XP user profile"
      <>http://support.Microsoft.com/kb/555473 >

    A corrupted user profile is often accompanied by file system errors.  A disk with the option/r or/f check should be performed as well.  Sometimes, this will solve your problem as well.  WARNING: A disk check will take hours to complete and can not be interrupted.  Run all night or when you won't need your computer for awhile.

    "How to perform disk error checking in Windows XP"
      <>http://support.Microsoft.com/kb/315265 >

    HTH,
    JW

  • How to cancel Adobe Creative cloud when you are blocked for a year after the first month and you need to pay 50% of the cost? Outregous!

    So bad that I couldn't cancel my subscription. A very big family problem is forcing me to cancel all my subscriptions, among them creative cloud. When you try to do, I learn I'm stuck unless I pay 50% of the cost of the remaining months. I am therefore be punished for having financial problems. The nice guy helped me with two months free, but the thing is 50%. You ever thing about future problems when you accept contracts like that. And they simply don't care. Adobe is so amazing, but so rigid. This is me.

    Hi Mario,.

    Please consult the General conditions of subscription as below:

    Adobe - General conditions of subscription

    The cancellation, have referred the help below document:

    Cancel your membership creative cloud

    You will need to contact customer service for cancellation requests.

    Kind regards

    Sheena

  • Launch of a scheduled task

    I have a business registration application that I launch a scheduled task at regular intervals so that I can record precisely what I'm getting.

    I recently thinapp had this request and now when the scheduled task starts, I see the toaster thinapp and then nothing.  I can see the processes running in the Task Manager, but I do not see the application gui/window (of course, there's a twist, see below *).

    So I thought that maybe there is something wrong with my thinapp so I tried another random application I'd thinapp would and same problem.

    All confirm that this also happens for them, or it's just me.

    Here's what I've tested so far.

    start notepad.exe from a schedule task works as expected.

    launch of my scheduled task thinapp does not want to show her face

    * However

    If I create a task of using command line to the interactive command-line (at 09:00 / interactive "C:\Prog...\thinapp'd app.exe") it works!

    But, if I go and edit this task through the graphical interface, the task stops running.

    So I can create a task that works, the only problem is that I can't put a timetable advanced assistance or schtasks.

    If someone else can replicate this to save my sanity, it would be very appreciated.

    I was able to reproduce the behavior you describe in your original post. What I found was:

    SOME ThinApped which are launched from a scheduled task programs have problems with GUI when you do not provide a password for it. It seems strange, but it seems that it is the cause.

    When I did not provide a password, I noticed that some programs ThinApped does not display its GUI although they run (as you can see in the Task Manager).

    On another application that I tested, it showed its GUI, but it covers the entire screen and it did not show its title/tool bars.

    This behavior doesn't happen with every ThinApped program, just with some of them.

    The workaround for this weird behavior is:

    -Provide a password for your scheduled task.

    -Turn off the checkbox "run only if connected.

  • Add-on of the Adobe Acrobat PDFMaker DC in Office 2010 Word does not store the bookmarks in the form of links

    I want to try Acrobat CD to see if it will generate PDFs from Word 2010 documents and preserve hyperlinks to bookmarks between documents correctly. I don't get work as I hope.

    I am running Windows 7 Enterprise. I have Adobe Acrobat installed DC (the trial version).

    I see the problem as shown in the following steps:

    1. Open Microsoft Word 2010
    2. Type a new text on the first page, but without adding a hyperlink yet.
    3. Save it as "origination.docx".
    4. Close this document.
    5. Open Microsoft Word 2010 again.
    6. Add text to the first page.
    7. Type CTRL + ENTER to insert a new page and on the second page, add text (it comes to check that the navigation between documents using hyperlinks on the bookmarks navigates to that favorite and is not just get stuck on the first page).
    8. Add a bookmark called "bookmark1.
    9. Save this document under "destination.docx".
    10. Close this document.
    11. Open the document "origination.docx".
    12. Insert a hyperlink to an existing document, and then select document "destination.docx". Click Favorites, and then select "bookmark1. Click ok:http://i.stack.imgur.com/fthuv.png
    13. Save this document.
    14. Select Acrobat menu, then click on create a PDF file:
    15. Click the Options button and in the window, select Convert favorite Word, and then click Ok and click Ok again.
    16. This saves the pdf file and then open it in Acrobat.
    17. Then I see this:
    18. Only one left clicking this link does nothing.
    19. Double left click on the link does nothing.
    20. Right mouse click on this link brings up a context menu that does not show that it is a link:
    21. That's why I can't do anything on this link is what I expected: I think it's a link, but instead, it's just text that happens to have the color of a hyperlink (blue).
    22. I opened the origination.docx and inspect the properties of hyperlink. Placing the cursor over the link in Word 2010 says:
    23. Right mouse clicking on the link and selecting Edit the hyperlink:
    24. Shows:
    25. The bookmark is correct as far as I can tell: I see destination.docx #bookmark1 in the address field.
    26. Click Ok.
    27. Then CTRL-click on the link to make sure it opens on "destination.docx", and he successfully navigate this bookmark in Word.

    So, what's the problem here?  Must Acrobat DC some additional preferences changes so that it works?

    Thank you

    BG

    (OT: there is no way to download files other than videos and images; otherwise I had to provide the .docx files).

    The option that you chose "Create bookmarks" aims to create bookmarks in Acrobat, which is a completely different concept of Word bookmarks. Is it creates bookmarks? The option isn't about bookmarks to links, and it is not clear that it should work.  Acrobat and PDF has never supported links TO a bookmark in a PDF document, somehow. Bookmarks are a feature of navigation manual, not a destination.

Maybe you are looking for