Contextual dialog box before you call network - not in the EXPECTED order

In my application, I would like to display a dialog box, while the application is retrieving data from a web server.  What I find is that the dialog box is not displayed until the data recovery is complete.  Don't know what I'm doing wrong, but here are my code snippets.  Suggestions are appreciated.

public class HomeScreen extends MainScreen  {

    private ImageScreen imageScreen;

    private MenuItem  viewImage = new MenuItem("View Image",100,10) {
      public void run() {
            imageScreen = new ImageScreen();            UiApplication.getUiApplication().pushScreen(imageScreen);
         imageScreen.getImage();
      }
    };}

public class  ImageScreen extends MainScreen {   private Dialog statusDlg; 

   public ImageScreen() {           statusDlg = new Dialog("Loading...",null,null,0,icon);       

       // some other initializations here   } 

    public void getImage() throws Exception {        statusDlg.show();

        // create the connection...        HttpConnection conn = (HttpConnection) Connector.open(URL,Connector.READ_WRITE, true);        conn.setRequestMethod(HttpConnection.POST);

        // set paramters and write out requests here        .        .        .

        // open input stream to get response from server        InputStream in = conn.openInputStream();

        // process the response        processResponse(conn.getResponseCode(), in);          

        // close everything out        .        .    }  

    public void processResponse(final int HTTPResponseCode, final InputStream inputStream)     {

      UiApplication.getUiApplication().invokeLater(new Runnable() {        public void run()        {          statusDlg.close();

          // process response here          .          .          .        }      });        }    

}

I want to see is a blank screen with a pop - up dialog box indicating that the data is "Loading"... ", while imageScreen.getImage () is executed (I voluntarily added latency in my HTTP response to simulate the network latency).  But instead, I see that the application remains on the screen (home screen), while the data are read.  Once the data is extracted, the new screen (ImageScreen) is displayed and the dialog box opens for a fraction of a second.

I hope this makes sense.  I can clarify more, otherwise.

It's because you make blocking network operation of e/s on the event thread (aka user interface thread). The getImage method is called on the thread of the event, this method calls the blocking network i/o operation. After processing the event of the user interface that caused the getImage method is called, the event thread starts processing the next events, which tells the OS to display your popup. This, obvsiouly, doesn't happen until GetImage ends.

What GetImage should probably do is network IO unloading in another thread (for example, starting a new thread).

Tags: BlackBerry Developers

Similar Questions

  • How can I call Save as dialog box before you download pdf files?

    How can I call Save as dialog box before you download pdf files?

    Here's my favorite scenario:

    1. the user clicks on the button

    2 Save as dialog box displays

    3. the user chooses the place

    4. a set of PDF files download here OR download a single zip file

    Background:

    I want to ensure that the user sees that the files are downloaded. I'm content to users who are not Web warned.

    Concern:

    1. the user has no idea how to find the downloaded files or files have even downloaded.

    2. I would like to deliver all in the form of zip files. Not sure if the automatic opening of zip files still exist.

    FOR INFO:

    I use jQuery UI buttons. Not sure if that factors in the response.

    Just for clarity, I'm not forcing a download. The user will click on a button.

    Click on a button or click on a link, either way you are technically running a script to force a download.

    I guess that's the PHP on the server.

    Yes but it is only a part of it.  Once the form runs, another script is called that opens the browser download dialog.

    Y at - it a php script to call the open/save dialog box?

    Yes.

    
    

    Name this file zip2download.php.

    Add a link to your HTML page:

    zip2download.php">Download the Zip

    Nancy O.

    ALT-Web Design & Publishing

    Web | Graphics | Print | Media specialists

    http://ALT-Web.com/

    http://Twitter.com/ALTWEB

    http://ALT-Web.blogspot.com/

  • How to remove the Save dialog box before you close the form?

    Hi all

    I've created a form that will open a data connection to a button click.

    I get the error on failure and the code to close my form of app.execMenuItem ("Close");

    but a save dialog box appears before I can close.

    (maybe because I did something on the opening form),

    It is able to remove it? Or simply impossible?

    Best rgds.

    Hmmm,

    What happens if you add?

    Event.Target.Dirty = false;

    app.execMenuItem ("Close");

  • Is there anyway to make Acrobat DC Pro (Win) pop up a warning dialog box before you print a PDF file?

    We have several very large PDFs on our web site that some want to have access to print. We don't mind them print the PDF files, but want to warn with a dialog box pop up that PDF files are hundreds of pages.  Is this possible with Acrobat Pro DC?

    Thank you

    Dave

    Hello

    It's absolutely to do a custom pop dialog that warn you when there is a big pdf for printing.

    However you will need JavaScript to create a code to perform this function.

    You can see the following link for the same.

    https://acrobatusers.com/tutorials/popup_windows_part5

    Concerning

    Sukrit diallo

  • encrypt/decrypt in Oracle Forms BEFORE you call an SP or the database DML statement

    Hello.  I'm working on an application where we need to encrypt information before it is sent to the database.  I know that the database has a great set of stored procedures to manage the encryption and decryption.  The only challenge here is the fact that I would need to send information unencrypted in the database "in the clear".  Ideally, I would like to encrypt the information in the form and send it to the database.  On recovery, recover the information and then have the application forms decipher encrypted information.

    Whoever did this as a package within a PLL without all calls to a package DBMS_?

    Thank you

    BradW

    OK, I think I have the solution.  We are going to import a java class that we create to do this for us.  We then import it in forms in a library of PLL.  Problem solved!

    Nice little intro to importing Java can be found here:

    Java in Oracle Forms without beans and pluggable Java components

  • Impossible to synchronize the folder unless 'See the improt dialog box before importing' is controls why?

    Synchronize folders only works if I 'See the import dialog box before importing' checked elsenever locates all the new files.

    Any ideas?

    Dave

    Hey big blue,

    This is a known problem with the latest version of Lightroom.

    Please click the link: sync folder fails with the error ' no photos or videos not found to import "

    Kind regards
    Tanuj

  • How to display the dialog box before uninstalling an application?

    Hello

    I want to display an alert dialog box before an application is uninstalled, has no idea how to do this?

    If not how can I detect a first run of an application after the installation?

    I have not tried out, just an idea.

    (A) there is a class called CodeModuleManager can check his stats module.

    So, in your application context thread to check his stats module.

    If it is marked as deleted, you can extract a global dialog box.

    (B) to implement SystemListener2, when the fastReset event occurs, you can check the stats module, if it is marked as deleted.

    you pop up GlobalDialog and force the user to interrupte.

    See you soon.

  • the contextual dialog box control

    Hello

    Is there a better method of positioning of a contextual dialog box under a control of the chain? -See attachment (run parent.vi)

    Can I get a ref section and a control string reference ref VI? while I need to pass the string ref

    Thank you

    Al

    You can use the 'Own VI' property for reference of the chain to get a reference to the parent VI. You can get the referral of the pane as well. Note: it must wire your clusters of error. Errors can and occur.

  • How can I access the standard import dialog box. Import button does not appear in the library module

    Only the clumsy 'compact' mode is now available. Forums and tutorials that show all 'standards' import dialog. Forum Adobe suggests installing earlier version. Please tell us how this can be done with CC

    BrianH

    You should always use the 2015.2 or 2015.2.1 version which had the modified import dialog box. Update LR 2015.3 through the creative cloud desktop application.

  • Using change in lightroom to open PS I no longer get the dialog box about how I want to open the picture

    When I use the command Edit from lightroom to open PS I no longer get the dialog box asking if I want to make copy, edit original or edit on lightroom adjustments someone can help me to change my setting I can get the dialog box?

    You get only this dialog box when you open certain file type and not with other files of type. You get the TIF, JPG and PSD dialog box. On the RAW files, that you don't have. A RAW file is still a RAW file and always will the changes you have made in LR when sending it Psalm if you save the RAW file in PS to JPG, TIF or PSD and close this file. Then return to LR and make adjustments more on it, or not, and then send it to PS you'll get this dialog.

  • Dialog box "Load WARNING summary": charge dependence of the new path

    Hi gurus of LabVIEW,.

    To explain the issue see the following behavior:

    My main Application is in

    01_Main.lvproj

    This project (01_Main) contain several baskets libraries built from another project file, let's say

    02_PPL.lvlibp

    03_PPL.lvlibp

    My problem comes when I opened the 01_Main.lvproj get the dialog box 'support WARNING summary": charge dependence of the new path.

    The gap between all the path's SVN folder that is duplicated;

    Track:

    SVN_Project/SVN_Project/02_PPL.lvlibp/Myinstr.VI

    NewPath: (which is the right of an ofc)

    SVN_Project/02_PPL.lvlibp/Myinstr.VI

    Opening Myinstr.vi in the containning the 02_PPL.lvlibp project does not appear of the warning... or the dependency problems.

    No idea how to solve those WARNING? Even if ignoring their job well... How to solve those for good?

    ARO

    Vincent


  • Some of function boxes are elongated and may not reach the OK box

    original title: Windows Vista - Control Panel customization to enlarge the font size.  Some of function boxes are elongated and may not reach the OK box

    Using Windows Vista. I used the customization Panel control to enlarge the font size.  I discovered that some boxes, like Adobe Reader Print and function, in effect, the Personaization (to reduce the font size to original size) require a click OK. But the box frame with large font size, is elongated until I can't get the OK.  How to get to the OK or reduce the size of the police without the OK?

    Simply press enter instead of OK.

  • I need help! I try to open my PDF but I get this message on my Macbook Pro! "Before you display PDF documents in the browser, you must launch Adobe Reader and accept the end user license agreement, and then quit and relaunch the browser."

    I need help! I try to open my PDF but I get this message on my Macbook Pro! "Before you display PDF documents in the browser, you must launch Adobe Reader and accept the end user license agreement, and then quit and relaunch the browser." What should I do?

    Do exactly what the message says, and it will go away.

  • I have a registration error trying to download a disc. It is said, your operating system Date and time format do not match the expected for PM Fastrack run format.

    Error in saving of the PM FASTrack.
    Impossible to analyze the dayYour operating system Date and time format do not match the expected for PM FASTrack run format. The format should be mm/dd/yyyy hh: mm:. The format is

    It's my complete error message. The time is set in this format on the computer. How should I do?

    Hello Murphy,

    Thanks for posting your question on the Forums of community of Microsoft.
    From the description of the question, I understand this format date and time do not match for PM FASTrack run.
    Let me go ahead and help you with the issue.
     
    You did changes to the computer before the show?
     
    I suggest for the link and follow the steps in the article, and check if this can help:
    Change the display of dates, times, currencies, and measures
     
    Also, check out the support links:
    PM FASTrack support.
     
    I hope this helps. If you have any other queries/issues related to Windows, write us and we will be happy to help you further.
  • Copy it / move the progress dialog box is absent and does not appear when you perform these tasks

    Whenever I have move, copy/paste or cut/paste between windows folder nothing happens initially. After 10 to 60 seconds (depending on the number and size of files) they suddenly all appear at the same time in the other folder or begin to be displayed one by one. Because no progress bar / dialog box appears, I don't know if something happens and I often repeat the process (although, without knowing it, the action takes place). In the task bar, the folder icon does not show even a progress bar green on the icon to show that all this is happening. This problem occurs in all situations and all types of files, be it between folders on the same drive or on a network drive. I recently did a clean install of Windows 8 and, as far as I know, there are no other programs or major processes that occur in the background that may interfere with my actions. Finally, I also note that copying/moving/deleting files takes a lot more time than my previous Windows 7 environment. a 20 MB file copy immediately before, but it takes now longer than 5 seconds to complete.

    Very frustrating.

    Thank you

    The f

    1. Use the Windows Media creation tool to create a USB bootable Windows 10.
    2. Boot from the USB key to clean Windows.
    3. Run Windows Update that there are no updates to be applied.
    4. Restart Windows

    It worked for me.

Maybe you are looking for

  • Add a location?

    I add old family photos to Photos. I know generally where these pictures were taken, but do not know the exact location. Hami to enter a generic place - "Indiana" or "Randolph County, Indiana" - Photos does not accept the location and I end up with a

  • popup Mega.viral - happy .site

    Right now, I have whenever I open safari and enter a link in google etc I just 'Mega. "viral - content .sire and he pop up" he said congratulations you won best and it windows pop up where I can only press 'OK '. What can I do? "I really want to keep

  • Lost the new Firefox button

    I had the button for some time, now only the FF logo at the top don't left, has no functionality. Where at - it go? Tried to download the 4.0.1 yet again, still no button

  • HP p2-1343w video card

    I have a HP p2-1343w desktop PC and I want to put a video in card so that my photoshop and games will run on choke, but not quite sure that the card mother will accept a. The mother board it is the APXD1-DM (Redwood (B) Any help will be great.

  • When I start the Director I get "the collection of files its not valid or its corrupted. A new empty collections file has been created ".

    I've been using Director windows 2.6 on my operating system from vista for several months.   I just did the upgrade to windows 7 and now I get this message. "The collection file is not valid or its corrupted." A new empty collections file has been cr