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
2
votes
2 answers

I get `android.os.NetworkOnMainThreadException` while using a seperate thread

In my Activity I use a handler Handler handler = new Handler() { @Override public void handleMessage(Message msg) { //do GUI stuff, edit views, etc.. } }; I also have a Runnable, which posts to php and waits for a…
tony9099
  • 4,567
  • 9
  • 44
  • 73
2
votes
2 answers

Locating UI code not on the platform / dispatch thread

I'm currently attempting to debug a medium scale (in the 10's of thousands of lines ballpark) Java project which uses both JavaFX and Swing, and I'm hitting some odd exceptions every so often which I'm pretty sure are because of UI code not being…
Michael Berry
  • 70,193
  • 21
  • 157
  • 216
2
votes
1 answer

C#/WPF - I can't update UI from a backgroundworker

I have a code that fetches tweets from a specific Twitter account using Tweetsharp library, creates instance of a custom UserControl and post tweet text to that UserControl then add it to a StackPanel. However, I have to get a lot of tweets and it…
Alaa Salah
  • 885
  • 1
  • 13
  • 23
2
votes
1 answer

Android Ui thread in loop

PROBLEM I have nearly 20 TextView and I need to have do something to make their background color change dynamically. For example: all TextView have same default background color then after 5 sec first one's will turn red where others still same…
Afbyk
  • 101
  • 2
  • 7
2
votes
0 answers

WPF Task on Touch device not back properly to UI Thread

I have a WPF application with some background tasks to be done that works perfectly on my laptop but it is not working fine in a tablet with Windows 7. You click the screen, a loading image is shown while some background job is done, and at the end…
Ivan BASART
  • 819
  • 2
  • 11
  • 15
2
votes
2 answers

Android: When to call invalidate()?

I'm using Matrix to rotate a PNG image on the screen. I want to move the rotation operation to a separate thread so the UI thread isn't burdened with it. But this raises some interesting questions. I expected to need to call invalidate() once the…
AndroidNewbie
  • 515
  • 5
  • 17
2
votes
1 answer

Why can I access only some UI control properties from BackgroundWorker?

I have a simple Windows Forms app that uses a couple BackgroundWorker elements to, well, do things in the background. While developing, I noticed I was able to do things such as get and set the .Text value of a Label in the DoWork() method, but am…
invertigo
  • 6,336
  • 5
  • 39
  • 64
2
votes
1 answer

WPF DataGrid - how to suspend UI updates from databind and do a bulk update later

Having to do a lot of cell-by-cell changes in code on my source DataTable, I need a way to temporarily halt it sending data-binding updates to its bound DataGrid: I have a DataGrid bound to a DataTable in code behind. DataGrid has defined columns…
user1250290
  • 123
  • 3
  • 12
2
votes
1 answer

MonoTouch, how to tell if I am on UI thread

The title says it all. I have a generic function that is used to run actions on the UI thread. I want to simple invoke the action if I am already on the UI thread. Is there a way to do this with MonoTouch?
Paul Knopf
  • 9,568
  • 23
  • 77
  • 142
2
votes
3 answers

Why isn't my progress dialog showing up?

In the code below, I have two fragments that get shown when their respective tabs are selected. Both of these fragments run asynctasks and are supposed to show progress dialogs while they do that. The first fragment (ndi) shows its progress dialog,…
Tyler Pfaff
  • 4,900
  • 9
  • 47
  • 62
2
votes
1 answer

How to implement a more flexible AsyncTask?

while it is very convenient to use, from my understanding, AsyncTask has two important limitations: doInBackground of any instances will share the same worker thread, i.e. one long running AsyncTasks can block all others. execute, onPostExecute…
Chris
  • 3,192
  • 4
  • 30
  • 43
2
votes
2 answers

ProgressBar and whole application freezes

I have an application and it freezes when I show a ProgressBar on the screen. When I increase the size of a ProgressBar or when I use a View instead of ProgressBar it doesn't freeze. When it freezes LogCat logs: D/OpenGLRenderer(13909): GL Error…
2
votes
2 answers

Android views can not be touched by other threads?

I am a newbie in Android and creating a mini FTP download manager for myself.. I am using multithreading, each thread to handle one download or upload. In the MainActivity.java, I am using two spinners in the view. One to list the files on the…
upInCloud
  • 979
  • 2
  • 10
  • 29
2
votes
1 answer

how to stop execution of UI thread until async task is complete to return value got in AsyncTask in android

I have a class in which I have written a AsyncTask to get Json from net. public class MyAsyncGetJsonFromUrl extends AsyncTask { Context context_; String url_; List params_; public…
user1699548
2
votes
3 answers

Does inline javascript block the UI thread?

I read this nice article on how external scripts block the UI thread but it wasn't clear to me whether the blocking is actually due to the presence of the