javacommons/utils/javasrc/com/nokia/mj/impl/coreui/CoreUi.java
changeset 80 d6dafc5d983f
parent 67 63b81d807542
--- a/javacommons/utils/javasrc/com/nokia/mj/impl/coreui/CoreUi.java	Mon Oct 04 11:29:25 2010 +0300
+++ b/javacommons/utils/javasrc/com/nokia/mj/impl/coreui/CoreUi.java	Fri Oct 15 12:29:39 2010 +0300
@@ -141,10 +141,56 @@
         }
     }
 
+    /**
+     * Executes given Runnable synchronously in UI thread.
+     * <br>
+     * This method should only be used in cases where it
+     * is absolutely needed. Before using this method,
+     * consider carefully if the use case really requires
+     * code to be executed in UI thread.
+     * <br>
+     * This method is only supported in Qt based runtimes.
+     * <br>
+     * @param runnable Runnable to be executed
+     * @throws RuntimeException if execution in UI thread
+     * is not supported
+     */
+    public static void runInSyncUiThread(Runnable runnable)
+    {
+        if (sInstance != null)
+        {
+            sInstance.runInSyncUiThreadImpl(runnable);
+        }
+    }
+
+    /**
+     * Executes given Runnable asynchronously in UI thread.
+     * <br>
+     * This method should only be used in cases where it
+     * is absolutely needed. Before using this method,
+     * consider carefully if the use case really requires
+     * code to be executed in UI thread.
+     * <br>
+     * This method is only supported in Qt based runtimes.
+     * <br>
+     * @param runnable Runnable to be executed
+     * @throws RuntimeException if execution in UI thread
+     * is not supported
+     */
+    public static void runInAsyncUiThread(Runnable runnable)
+    {
+        if (sInstance != null)
+        {
+            sInstance.runInAsyncUiThreadImpl(runnable);
+        }
+    }
+
     protected abstract boolean connectToUiImpl();
     protected abstract void createUiImpl(Uid uid, boolean backGroundStart);
     protected abstract void shutdownRequestImpl();
     protected abstract void foregroundRequestImpl();
     protected abstract boolean isUiInForegroundImpl();
     protected abstract void hideApplicationImpl(boolean hide);
+    protected abstract void runInSyncUiThreadImpl(Runnable runnable);
+    protected abstract void runInAsyncUiThreadImpl(Runnable runnable);
 }