Questions tagged [ui-thread]

In some frameworks there's a dedicated thread that exclusively manages all UI objects. It's the developer's responsibility to use this thread for UI updates (e.g. adding, updating and removing controls).

In some frameworks (.Net, Android, iOS, Java Swing etc.) there's a dedicated thread that exclusivly creates and manages all the UI objects. Only this thread is allowed to modify UI objects (add, remove, set text on the button, etc). Other threads usually just post a request to make such modifications.

UI thread must never be paused for long with slow task (like communication over network or something computation intensive) as this would make all GUI non-responsive.

References

599 questions
6
votes
1 answer

Should Control.InvokeRequired always be used when accessing UI controls

We are building a .NET application using WinForms (3.5). I have added a new feature recently, and started experiencing weird behavior when accessing certain controls. The problem was that some UI control access simply halted the execution (no…
lysergic-acid
  • 19,570
  • 21
  • 109
  • 218
5
votes
1 answer

How to do expensive operation in the app itself like searching in large list in react native?

I have a json of 10000 records which I need to show in a Flatlist.I am using a virtualized list which is working fine.Now I have certain filters which on click should filter out the json and re render the list with the new data.I am simply filtering…
sang
  • 109
  • 1
  • 1
  • 10
5
votes
1 answer

admob: How to load AdRequest outside of UI Thread?

I have a game which has ads in it.I eventually found the source of lag is basically because of the adRequest process which takes a long time. super.onCreate(savedInstanceState){ mainLayout = new LinearLayout(this); …
Fugogugo
  • 4,460
  • 10
  • 36
  • 50
5
votes
2 answers

How do I know if an async method call changes the caller's context?

Consider this example: async Task Foo() { button.Text = "This is the UI context!"; await BarA(); button.Text = "This is still the UI context!"; await BarB(); button.Text = "Oh no!"; // exception (?) } async Task BarA() { …
matt-pielat
  • 1,659
  • 3
  • 20
  • 33
5
votes
3 answers

Android ProgressDialog won't spin

This is my fist stackoverflow post so please be gentle with me! I'm sure that what i'm trying to do is possible and it is something I have done (or not done?) that is causing the problem... I'm just not sure what that something is. What i'm trying…
John
  • 1,466
  • 3
  • 21
  • 38
5
votes
0 answers

Android Database operation in Asynctask blocks UI Thread

I'm performing a Database operation in the doInBackground method inside an AsyncTask on Android. For some reason, the UI get blocked during the 5-6 seconds that the operation takes. It does not make any sense for me, the operacion inside the…
Ale
  • 2,282
  • 5
  • 38
  • 67
5
votes
2 answers

Can't create handler inside thread that has not called Looper.prepare()3

public class AddStudentActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_add_student); } public void add2(View view){ …
Yu Wil Son
  • 119
  • 2
  • 11
5
votes
5 answers

Interacting with UI threads in Java/J2ME

I'm writing a J2ME application. One of the pieces is something that polls the contents of a directory periodically, and, if there are any new things, paints them on the screen. I've done this by having the UI form launch a polling thread with a…
Cory
  • 22,772
  • 19
  • 94
  • 91
5
votes
3 answers

Guice creates Swing components outside of UI thread problem?

I'm working on Java Swing application with Google Guice as an IOC container. Things are working pretty well. There are some UI problems. When a standard L&F is replaced with Pushing pixels Substance L&F application is not running due to Guice's…
Boris Pavlović
  • 63,078
  • 28
  • 122
  • 148
5
votes
2 answers

Adding Markers in Background while Looping through ArrayList

I add Markers to a googleMap from an ArrayList of Objects. There are about 250 markers; I even have to convert them to bitmaps to customize them. It's a pretty resource intensive task. BUT It seriously blocks my UI thread. Here is how I do it: …
TheLettuceMaster
  • 15,594
  • 48
  • 153
  • 259
5
votes
1 answer

Android view not shown after addView method

I have an issue with ViewGroup.addView() method. I use this code to add new view to my layout: TalbeLayout parent = (TableLayout)findViewById(R.id.this_does_not_matter); parent.removeAllViews(); //this view group contains something at start TextView…
user3390963
  • 2,313
  • 1
  • 13
  • 12
5
votes
2 answers

Understanding the UI thread

I am a beginner to Android and I have some confusions regarding Android UI Thread. Now, I know that no thread apart from the one that created the UI can modify it. Great. Here is the Activity from my first Android app which slightly confuses me. …
An SO User
  • 24,612
  • 35
  • 133
  • 221
5
votes
2 answers

LocationManager: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()

Normally an error while doing something on the UI thread from another thread I thought, but I don't get what I'm doing wrong. The error seems only to appear when the phone is travelling, so with a changing GPS location. I want the most recent…
Diego
  • 4,011
  • 10
  • 50
  • 76
4
votes
3 answers

Android onLayout() and AsyncTask() does not work together

I need a scrollable table with fixed header, so I followed this great blog and everything is fine. The idea is using one table for header, one table for content added in scrollview, both of them are in a customized LinearLayout. In customized…
thanhbinh84
  • 17,876
  • 6
  • 62
  • 69
4
votes
3 answers

doInBackground calling AsyncTask then sleeps blocks UI Thread

I have an activity, composed of an AsyncTask aiming to launch a request when the user clicks on the button. I have been looking for answers, but I didn't find the same problem, or it didn't the same for me. The code is doing what I want, but the…
Camille R
  • 1,433
  • 2
  • 17
  • 29