ui-thread

Children of LinearLayout not drawn when returning from another activity

旧时模样 提交于 2021-01-29 16:47:43
问题 On app startup, all children of the LinearLayout (LL) are rendered. But, with the same code when coming from another activity, no children of the LL are visible, nevertheless included in the view tree. See: The activity_main.xml is: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:id="@+id

LeakCanary (2.0) blocking the main thread causes my instrumentation tests to fail

試著忘記壹切 提交于 2021-01-29 13:36:57
问题 when I run my instrumentation tests against the debug version of my app, leak canary will block the UI thread and cause the instrumentation test to fail. I had to revert to the old version. Is there any way to avoid the leakcanary UI or companion app (not sure what is blocking the UI thread) from running, while running the instrumentation tests? Thanks 回答1: See the doc: https://square.github.io/leakcanary/recipes/#running-leakcanary-in-instrumentation-tests LeakCanary automatically disables

Is it ok accessing [UIApplication sharedApplication] from background thread?

前提是你 提交于 2021-01-28 09:33:51
问题 While working on Objective-C , I need to get the protectedDataAvailable status possibly inside some background threads. - (BOOL) isProtected { BOOL protectedDataAvailable = [[UIApplication sharedApplication] isProtectedDataAvailable]; return protectedDataAvailable; } As I am accessing [UIApplication sharedApplication] , I suspect that the code block should run in main queue. How can I do so? I was thinking to change it like, - (BOOL) isProtected { BOOL protectedDataAvailable = NO; dispatch

Is it ok accessing [UIApplication sharedApplication] from background thread?

僤鯓⒐⒋嵵緔 提交于 2021-01-28 09:31:54
问题 While working on Objective-C , I need to get the protectedDataAvailable status possibly inside some background threads. - (BOOL) isProtected { BOOL protectedDataAvailable = [[UIApplication sharedApplication] isProtectedDataAvailable]; return protectedDataAvailable; } As I am accessing [UIApplication sharedApplication] , I suspect that the code block should run in main queue. How can I do so? I was thinking to change it like, - (BOOL) isProtected { BOOL protectedDataAvailable = NO; dispatch

How to avoid cross-thread operation not valid exception in Winform service bus message receiver

老子叫甜甜 提交于 2020-07-03 12:00:58
问题 Have developed an Azure service bus message receiver console app which is working fine console app. Code for console app as follows: using System.IO; using Microsoft.ServiceBus.Messaging; class Program { static void Main(string[] args) { const string connectionString = "Endpoint=sb://sbusnsXXXX.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=bkjk3Qo5QFoILlnay44ptlukJqncoRUaAfR+KtZp6Vo="; const string queueName = "bewtstest1"; var queueClient = QueueClient

Showing a text indicator before freezing the Silverlight UI thread

≡放荡痞女 提交于 2020-02-06 04:08:12
问题 At some point in my Silverlight application I need to perform a heavy operation which freezes the UI thread for about 4 seconds. Before actually performing the operation I am trying to display a simple text indicator via a TextBlock control. StatusTextBlock.Text = "Performing Some Operation..."; System.Threading.Thread.Sleep(4000); // Just as an example The problem is that the UI thread freezes before the text of the TextBlock control gets updated. How can I get the notification text shown

Force redraw before long running operations

此生再无相见时 提交于 2020-01-19 04:00:43
问题 When you have a button, and do something like: Private Function Button_OnClick Button.Enabled = False [LONG OPERATION] End Function Then the button will not be grayed, because the long operation prevents the UI thread from repainting the control. I know the right design is to start a background thread / dispatcher, but sometimes that's too much hassle for a simple operation. So how do I force the button to redraw in disabled state? I tried .UpdateLayout() on the Button, but it didn't have any

How to make timer task to wait till runOnUiThread completed

十年热恋 提交于 2020-01-15 06:22:12
问题 I need to update UI after certain time period, for which I have create a timer schedule and inside it I am calling the runOnUiThread. timer.scheduleAtFixedRate(new TimerTask() { public void run() { System.out.println("1"); try { System.out.println("2"); System.out.println("3"); runOnUiThread(new Runnable() { public void run() { System.out.println("4"); System.out.println("5"); System.out.println("6"); System.out.println("7"); } }); System.out.println("8"); } catch (Exception e) { e

UI Stucks in iOS app possible reason is FMDB query?

柔情痞子 提交于 2020-01-07 03:10:34
问题 my apps UI stuck for several seconds for the very first time app launches (MenuPage) and when I move to Account page. It stuck while calculating some status. But I did them in background queue. I paused and looked at the debugger. Its shows this: I am giving the codes from account page as it is much clean than the menu page. From account page I am calling SyncStatus like this: dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ [_syncStatus startStatusCalculating]

Will Runnables block the UI thread?

你离开我真会死。 提交于 2020-01-02 11:06:13
问题 I am trying to understand how UI thread's event queue works. I'm trying to run a code that can be broken into many parts but unfortunately it must run on the UI thread. So, in order to not block the UI thread and receive a ANR I was wondering if I can break that code in many Runnable objects and run them using runOnUiThread from another thread. My question is, will this block the UI thread? If, for example, I have a piece of code that definitely runs in over 5 seconds and I break this code