Displaying a Dialog.alert once a thread has ended?

I'm having some problems with this and then I just a thread that makes treatment and after treatment is finished I want to inform the user with a simple Dialog.alert that has finished processing.

Thread MyThread = new Thread();
thread. Start();

Dialog.Alert ("files have been processed!");

Of course if I do this, the dialog box is in place until treatment is completed. I can get this work done a thread.join () but I said that I should avoid this.

"I get a lock event in the thread at the end, I'm doing an anti-pop"

I would recommend not getting the lock of the event.  Use invokeLater where you can, invokeAndWait when you need to wait and get the event only lock where you know it will work.  In this case, you must put the pop filter and the dialog in a Runnable invokeLater.  This will work.  You have discovered, dialogue and event lock do not work together.

Regardless, I would recommend using the model of the observer.  Your background Thread should not have to know anything abut the UI components.

Tags: BlackBerry Developers

Similar Questions

  • Display a dialog box after the ejection of a USB drive, saying the car was ejected

    Hi, would someone please tell me how to change the applescript below to eject my USB in 2 ways, either by waiting 30 seconds by pressing the button "YES". Then, once the disc has been ejected another dialog box would appear to say 'eject disk '. If 'NO' button has been activated the reader wouldn't be ejected. My USB is indicated as (the present book).  Thanks in advance for any help.

                                                                tell application 'Finder '.

    display the dialog box "Eject USB drive?" default button 1 with the title "Eject?" buttons {'yes', 'No'} give up after 30

    If the button returned of the result is 'yes' then ejection of the this book

    tell the end

    Here:

    Tell application "Finder".

    Display dialog "Eject USB Drive?" buttons {"Yes", "No"} default button 1 with the title "Eject?" give up after 3

    If the result back button is 'yes' or abandoned then of the result

    This book of ejection

    display the dialog box 'Disc ejected.'

    end if

    tell the end

    (143586)

  • Dialog.Alert () and discussions seem to collide.

    Whenever I start a new thread in the main program, it works fine until I just change a few numbers, or output to sysout. Whenevery I use a Dialog.alert from a thread, I receive a RuntimeException.

    I tried from the main class as an argument to the thread, and then leave the thread executing a mainclass.displayPopup () custom; function popups the but he still doesn't have with a runtimeException

    I do not understand the use of Threads? I want a Dialog.alert () at 3 seconds after the screen apear as soon as the screen that contains the main code is pushed...

    To start a separate Thread, you use start:

    This.qdist.Start ();

    If you are using

    This.qdist.Run ();

    then you ask just the run method on your own Thread.

  • Displaying a dialog box to a background thread listening thrust

    Hi, my request has an Autostart entry point and a normal entry point. On Autostart, I start a thread to listen push. When this background process receives a msg to push, I want to display a dialog box to the user (from the background process). I tried many solutions I found on this forum and tried the code in this article: http://supportforums.blackberry.com/t5/Java-Development/Alert-a-BlackBerry-smartphone-user-from-a-Ba....

    When you use the code in the KB article, the unit freezes and I have to remove the battery...

    My application extends UIApplication, is there another way to do it?

    Thank you!

    Well, I managed to do work by creating a class that extends the Application of my background process and do enter the thread of events.

  • Display a dialog thread not event

    I need to display a dialog of another point of entry (arrival of a push message).

    To do this, I need to create an instance of the Application on the other entry point and listen to push enter.

    The problem is when I express my application calls enterEventDispatcher() and UiApplication class. the other entry point, it shows an application icon in the execution of applications forever (seen by menu button).

    I need listen to push messages and alert user by a dialog box without going through an application icon.

    So is it possible that I can show a dialog to the other entry point without a UI event thread? If not, then what is the use of push if you can't attract the attention of the user?

    Help, please. Stuck!

    Thanks in advance.

    Afzal

    You could create an Application (instead of a UiApplication) instance and then use this:

    http://supportforums.BlackBerry.com/T5/Java-development/alert-a-BlackBerry-Smartphone-user-from-a-BA...

  • Dialog.Alert () cannot display in implements method

    class DialogCommandHandler extends CommandHandler
    {
        public void execute(ReadOnlyCommandMetadata metadata, Object context)
        {
            if (context.equals(contextSearch)) {
                Dialog.alert("Coming soon!");
            }
        }
    }
    

    Hi, everyone, I found this problem while I'm my debugger application, execution implements net.rim.device.api.command.CommandHandler.execute, in that implements Dialog.alert () cannot display my warning, I've tried with/without synchronized invokeAndWait() and invokeLater() (Application.getEventLock ()) {}, each of them did not work properly, is there a solution for this problem, or is it a question? Thank you! ~

    Can you describe what is happening?  There is an exception thrown?  Or the treatment stops right?

    In this case, I think the correct 'packaging' for this, is an invokeLater.  I think that the other options will cause a blockage.  So, your code will be something like:

    If (context.equals (contextSearch)) {}

    UiApplication.getUiApplication.invokeLater (new Runnable() {}

    public void run() {}

    Dialog.Alert ("Coming soon!");

    }

    });
    }

  • How can I do to block the main thread when to display a dialog box

    I have a problem to block the user interface main thread when to display a dialog box (the dialog was created by the main Application), and when the dialog box is closed, the main Application can go to the next step.
    Here is my code:

    SerializableAttribute public class TitledPaneExample extends Application {}
    instance of TitledPaneExample private;
    StackPane mainModalDimmer;

    /*
    * (non-Javadoc)
    *
    * @see javafx.application.Application #start (javafx.stage.Stage)
    */
    @Override
    public void start (point primaryStage) bird Exception {}
    instance = this;
    primaryStage.setTitle (this.getClass () m:System.NET.SocketAddress.ToString ());

    final StackPane layerPane = new StackPane();
    layerPane.setDepthTest (DepthTest.DISABLE);
    layerPane.setStyle ("background - fx - color: BLACK ;"); ")

    Vb VBox = new VBox();
    vb.setStyle ("background - fx - color: BLUE ;"); ")
    vb.getChildren () .add new (Label ("1"));
    vb.getChildren () .add (Label ("2")) new;
    vb.getChildren () .add new (Label ("3"));
    vb.getChildren () .add (Label ("4")) new;

    Bt1 button = new Button ("bt1");
    BT1.setOnAction (new EventHandler < ActionEvent > () {}
    {} public void handle (ActionEvent event)
    System.out.println ("bt1 trying to the new dialog box > > >");
    Dialogue di = new dialog box (instance, "some trick here!");
    System.out.println ("bt1 dialogue again successfully, try to show");
    di. Show();
    System.out.println ("bt1 dialog hide? < < < < ");"
    }
    });
    vb.getChildren () .add (bt1).

    layerPane.getChildren () .add (vb);

    mainModalDimmer = new StackPane();
    mainModalDimmer.setId ("MainModalDimmer");
    mainModalDimmer.setMaxSize (Double.MAX_VALUE, Double.MAX_VALUE);
    mainModalDimmer.setVisible (false);
    mainModalDimmer.setStyle ("background - fx - color: RED ;"); ")
    layerPane.getChildren () .add (mainModalDimmer);

    Scene sc = new scene (layerPane, 800, 600);
    primaryStage.setResizable (true);
    primaryStage.setScene (sc);
    primaryStage.show ();

    }

    /**
    * Display the node given as a floating dialog on the entire application, with
    * the rest of the application grayed out and blocked from mouse events.
    *
    @param message
    */
    {} public void showModalMessage (message from node)
    mainModalDimmer.getChildren () .add (message);
    mainModalDimmer.setOpacity (0);
    mainModalDimmer.setVisible (true);
    mainModalDimmer.setCache (true);
    TimelineBuilder
    . Create()
    () .keyFrames
    new KeyFrame (Duration.seconds (1),)
    new EventHandler < ActionEvent > () {}
    {} public void handle (ActionEvent t)
    mainModalDimmer.setCache (false);
    }
    }, new KeyValue (mainModalDimmer
    . opacityProperty(), 1.
    Interpolator.EASE_BOTH))) infrastructure)
    . Play();
    }

    /**
    Hide the any modal message that appears
    */
    public void hideModalMessage() {}
    mainModalDimmer.setCache (true);
    TimelineBuilder
    . Create()
    () .keyFrames
    new KeyFrame (Duration.seconds (1),)
    new EventHandler < ActionEvent > () {}
    {} public void handle (ActionEvent t)
    mainModalDimmer.setCache (false);
    mainModalDimmer.setVisible (false);
    mainModalDimmer.getChildren () .clear ();
    }
    }, new KeyValue (mainModalDimmer
    . opacityProperty(), 0,.
    Interpolator.EASE_BOTH))) infrastructure)
    . Play();
    }

    /**
    @param args
    */
    Public Shared Sub main (String [] args) {}
    Launch();
    }

    Dialogue/public class extends TitledPane {}
    private owner of TitledPaneExample = null;
    instance of TitledPane private;

    Dialogue (owner of TitledPaneExample, String message) {}
    This.Owner = owner;
    this.parentThreand = Thread.currentThread ();
    This.instance = this;
    this.setExpanded (true);
    this.setText ("Dialog");
    this.setMaxWidth (400);
    this.setPrefWidth (300);
    this.setMinWidth (200);

    Label the tx = new Label ("message");
    tx.setTooltip (new Tooltip (message));
    tx.setWrapText (true);
    tx.setContentDisplay (ContentDisplay.LEFT);

    Bt button = new Button ("OK");
    bt.setOnAction (new EventHandler < ActionEvent > () {}
    {} public void handle (ActionEvent event)
    masquer();
    }
    });

    Sp ScrollPane = new ScrollPane();
    sp.setHbarPolicy (ScrollBarPolicy.AS_NEEDED);
    sp.setVbarPolicy (ScrollBarPolicy.AS_NEEDED);
    sp.setContent (tx);

    Hb HBox = new HBox (30);
    hb.setPrefHeight (40);
    hb.setAlignment (Pos.CENTER_RIGHT);
    hb.getChildren () .add (bt);

    BP BorderPane = new BorderPane();
    bp.setCenter (sp);
    bp.setBottom (hb);

    this.setContent (bp);
    }

    {} public void show()
    System.out.println ("dialogue show() 1 > > >");

    owner.showModalMessage (instance);

    System.out.println ("dialogue show() 2 > > >");

    }

    public void masquer() {}
    System.out.println ("dialogue masquer() 1 > > >");
    this.owner.hideModalMessage ();

    System.out.println ("dialogue masquer() 2 > > >");
    }
    }

    }

    I'm also interested in how to do this without the use of a step.

    But, if you are ready to use a step for this, you can create a useful first step (without borders) with its owner being your current stage. Then, you can call the function showAndWait on stage that allows to block the thread of your application. For example, I implemented a DialogStage like this:

    package hs.mediasystem.util;
    
    import javafx.animation.KeyFrame;
    import javafx.animation.KeyValue;
    import javafx.animation.Timeline;
    import javafx.event.EventHandler;
    import javafx.scene.effect.ColorAdjust;
    import javafx.stage.Modality;
    import javafx.stage.Stage;
    import javafx.stage.StageStyle;
    import javafx.stage.Window;
    import javafx.stage.WindowEvent;
    import javafx.util.Duration;
    
    public class DialogStage extends Stage implements Dialog {
    
      public DialogStage() {
        super(StageStyle.TRANSPARENT);
    
        this.setTitle("MediaSystem-dialog");
    
        initModality(Modality.APPLICATION_MODAL);
      }
    
      protected void setParentEffect(Stage parent) {
        ColorAdjust colorAdjust = new ColorAdjust();
    
        Timeline fadeOut = new Timeline(
          new KeyFrame(Duration.ZERO,
            new KeyValue(colorAdjust.brightnessProperty(), 0)
          ),
          new KeyFrame(Duration.seconds(1),
            new KeyValue(colorAdjust.brightnessProperty(), -0.5)
          )
        );
    
        parent.getScene().getRoot().setEffect(colorAdjust);
    
        fadeOut.play();
      }
    
      protected void removeParentEffect(Stage parent) {
        parent.getScene().getRoot().setEffect(null);
      }
    
      protected void recenter() {
        Window parent = getOwner();
    
        sizeToScene();
    
        setX(parent.getX() + parent.getWidth() / 2 - DialogStage.this.getWidth() / 2);
        setY(parent.getY() + parent.getHeight() / 2 - DialogStage.this.getHeight() / 2);
      }
    
      @Override
      public final void showDialog(final Stage parent, boolean synchronous) {
        initOwner(parent);
    
        setParentEffect(parent);
    
        setOnShown(new EventHandler() {
          @Override
          public void handle(WindowEvent event) {
            recenter();
            onShow();
          }
        });
    
        if(synchronous) {
          showAndWait();
        }
        else {
          show();
        }
      }
    
      protected void onShow() {
      }
    
      @Override
      public void close() {
        removeParentEffect((Stage)getOwner());
        super.close();
      }
    }
    
  • Dialog.Alert give runtime exception

    Hi all

    I have a scenario, whiich am thrown in runtime exceptions.

    I placed a dialog.alert to show the user an alert after a validation. It works fine, but once when I cllicked on the ok button, it TR throwing a runtime exception. She did not understand why clicking on the alert of dialogue in which run-time exception.

    In some screens, he of not throwing the error and works very well.  I have observed that, the error is thrown in cases where a custom editfield is added to the screen.

    Please explain to me why this is happening and how to understand it. .?

    Thanks to everyone for your interest!

    After a long vacation... so this thread remains as it is. I found the mistake during debugging. There is no detailed msg that are associated with. and it is originally due to "TouchEventInjector" will be void. I haven't heard of him until now.

    I don't know yet why it start error.

    but I solved my problem by pushing an anti-pop as alert msg.  I wl mrk this thread as solved after awhile, looking for ideas about this error.

  • How to display an automatic alert message?

    I'm listening to incoming e-mail messages and must display an alert if an incoming message arrives with a HIGH priority.

    I can listen and view a message using System.out.println. But I can't able to show a Dialog.alert ("new E-mail message");

    It shows the following error message:

    "" Eception exception: pushModalScreen called by a thread of non-event ".

    I tried to call through invokeLater, but both EventQueue and SwingUtilities are not available with BlackBerry JDE 4.7.0.41

    How can I display an alert automatically, when a new HIGH-priority message arrives? Is all classes available for this purpose?

    Here is an article from the second suggestion of Simon documents.

    How - to alert a user to a background application
    Article number: DB-00407
    http://www.BlackBerry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800608/...

    Edit: Just found this, which I think that documents first suggestion of Simon:

    How to allow - a listener in the background to detect and update a GUI application
    Article number: DB-00406
    http://www.BlackBerry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800451/800783/How_To _...

  • Displaying a dialog at startup

    I'm in DW CS3 for Windows. I'm writing an extension that will display a dialog at startup box. 'Extension of Dreamweaver' manual says: "If you place a command file in the Configuration/startup folder, the command runs as Dreamweaver starts." I did this. This code executes. He said, "you can also view warnings, prompts the user for more information or call the function dreamweaver. RunCommand (). ' Call Dreamweaver.RunCommand () doesn't seem to work. Can I put the same code in a command that runs after the start and it works fine, but in my startup command, it seems that Dreamweaver does not know just my calls to runCommand().

    Specifically, my startup command contains:
    Alert ('before');
    dreamweaver.runCommand ('myCommand.htm');
    Alert ('alert');

    I see the 'before' and 'after' alerts, but I do not see the dialog box defined in myCommand.htm.

    Do you have a suggestion?

    Thank you

    Leif

    "rolw" wrote in message
    News:fhcnqk$BM2$1@forums. Macromedia.com...
    > Yes, thanks for asking. My order has a shape. I threw a few
    > entry tags for good measure. My dialog box still does not appear.

    As a workaround, you can change your order an order for _onOpen released
    by adding the file name, _onOpen
    then set a flag you next time to not show the dialog box.

  • Firefox plays after clicking on links for her instead of display the dialog box for play/download mp3/wav

    Firefox when trying to play wavs/mp3s after clicking on link to it instead of display the dialog to open/download. In preferences on the applications tab, I always chose "ask" in the types of wav and mp3 files, but it does not solve this problem.

    This has happened

    Each time Firefox opened

    == I'm not sure

    Firefox will play the file if you have a drive installed that supports the mime type that the server sends to this file.

    See "File handling in Firefox 3 and SeaMonkey 2": http://kb.mozillazine.org/File_types_and_download_actions

  • Call Dialog.ask in the Thread Run method

    "in I want to call Dialog.alert and using following code but its exception to throw the wire.

    "Exception occurs java.lang.RuntimeException: pushModalScreen called by a thread of non-event."

    synchronized (Application.getEventLock ())

    {

    if (Dialog.ask ("catalog is obsolete. You want to keep it? ", choices, select, select [0])(==1)"

    {

    Run the required functionality

    }

    }

    pls help me

    I keep saying this, so forgive me of repeating myself, but:

    synchronized (Application.getEventLock ()) {}

    should only be used when nothing else will work for you or you make a very simple, very fast UI update.

    A Dialog.ask is not very fast!

    In this case, you have several options, but the most obvious solution is to ask the question before starting the Thread.  So, if that is your treatment

    Thread catUpdateThread = new Thread() {}

    public void run() {}

    Dialog.ask (...)

    Other treatments

    }

    }

    catUpdateThread.start ();

    What should do the same and works OK. :

    UiApplication.getUiApplication.invokelater (new Runnable() {}

    public void run() {}

    Dialog.ask (...)

    If (result == Yes) {}

    Thread catUpdateThread =...;

    catUpdateThread... Start();

    }

    }

    });

  • Sierra update once the photos has been repaired all of my albums have been removed, videos and all album

    After the update of Sierra once the photos has been repaired all of my albums have been removed from my album of videos from photo library and all, only defalt albums that are there are people, last imported and my photo stream.

    If the videos, Burst, Slow Mo, time, selfies are all gone?

    Please help someone

    Videos are, Burst, Slow Mo, time, selfies albums in the missing sidebar or the content of these missing albums?

    You have a copy backup of the library made just before your Sierra improvement?

  • When using a 2010 macbook pro and a mini display port to hdmi adapter, will be the macbook pro display be sent to a TV that has hdmi inputs, or do you need a keyboard command

    When using a 2010 macbook pro and a mini display port to hdmi adapter, will be the macbook pro display be sent to a TV that has hdmi inputs, or do you need a keyboard command

    Yes it will be displayed.

  • I did this, copied my iTunes from iMac to Macbook Pro folder, and my playlists are not displayed on my Macbook. My iMac has been reformatted since... Is it possible to get my playlists?

    I did this, copied my iTunes folder of iMac to Macbook Pro according to the tutorial below, and my playlists are not displayed on my Macbook. My iMac has been reformatted since... It was my mistake, fitness before seeing that my playlists were not on my Macbook. Is it possible to get my playlists?

    https://support.Apple.com/en-us/HT204318

    Probably put you the folder in the normal position inside the music.  Launch iTunes while holding down the option/alt key and navigate to the iTunes Library.itl file in the folder that you moved.

Maybe you are looking for