B4J Question Mouse Cursor Delay in Changing

Discussion in 'B4J Questions' started by melliott, Apr 3, 2015.

  1. melliott

    melliott Member Licensed User

    Hello,

    Just before performing a timely operation I am setting the mouse cursor to WAIT as so:

    MainFrom.RootPane.MouseCursor = fx.Cursors.WAIT

    When I add the code for my long running process after the above line (which connects to a database) the cursor does not change. I tried putting a huge for-loop before it and also using a timer. Still, my mouse cursor changes after my process.

    What can you recommend to get the MouseCursor to be visible as fx.Cursors.WAIT before my process runs?

    Thanks,

    Michael
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Can you provide more information about the timely operation? Why is it slow?
     
  3. melliott

    melliott Member Licensed User

    >> Can you provide more information about the timely operation? Why is it slow?

    I am using jSQL to connect to multiple databases to get stats. I would not say it is slow - just takes about 5-15 seconds to connect to the databases and get the values. It works fine. I'd like to simply change to cursor to an hour glass before the process starts then change it back after the process.

    In tests I have no issue changing the cursor to an hour glass via: MainFrom.RootPane.MouseCursor = fx.Cursors.WAIT

    For some reason issue that code then attempting to connect to multiple databases via jSQL inhibits that cursor from changing.

    conn.InitializeAsync("conn", "oracle.jdbc.driver.OracleDriver", _
    "jdbc:racle:thin://DB01:1521/MyDB","SCOTT","tiger")

    <<add values to TableView1 from ResultSet >>

    conn.InitializeAsync("conn", "oracle.jdbc.driver.OracleDriver", _
    "jdbc:racle:thin://DB02:1521/MyDB","SCOTT","tiger")

    <<add values to TableView1 from ResultSet >>

    conn.InitializeAsync("conn", "oracle.jdbc.driver.OracleDriver", _
    "jdbc:racle:thin://DB03:1521/MyDB","SCOTT","tiger")

    <<add values to TableView1 from ResultSet >>

    MainFrom.RootPane.MouseCursor = fx.Cursors.DEFAULT





    What can you recommend?
     
    Last edited: Apr 6, 2015
  4. Erel

    Erel Administrator Staff Member Licensed User

    Where is the code that handles the Ready event?
     
  5. melliott

    melliott Member Licensed User

    Sub conn_Ready (Success As Boolean)
    If Success = False Then
    Log(LastException)
    Return
    End If
    End Sub
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    InitializeAsync is a non-blocking call. This means that you are changing the cursor to the wait cursor and then immediately change it back to the default cursor.


    I don't see how your code can work as you are reading from the connection before it is ready. You can only work with the connection after the Ready event is raised.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice