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
0 answers

Immersive mode throws exception in NDK even though it is called from main thread

When I try to set sticky immersive mode via JNI using the Java method "setSystemUiVisibility" the exception "Only the original thread that created a view hierarchy can touch its views." is thrown. However, the function is called right when I get the…
2
votes
1 answer

Call functions that require the main thread from different fibers

There are lots of functions that are supposed to be called from the main thread. In my limited experience, these are mostly UI functions. Examples: -[UIApplication delegate] must be called from main thread only) java.lang.IllegalStateException:…
sudo rm -rf slash
  • 1,156
  • 2
  • 16
  • 27
2
votes
0 answers

cross thread operations issue while invoking method

I'm Creating a notepad application in c# with the use of the task parallel library.But after about 2 seconds of typing I get an invalid operation exception due to cross thread calls(spellchecker) or sometimes the UI freezes as well. Could someone…
2
votes
1 answer

Is checking the Thread is "UI Thread" before Calling Dispatcher.Invoke redundant?

In regards to Application.Current.Dispatcher.Invoke(action); I have looked at CheckAccess() and various ways of determining whether i'm on the main UI thread. Though after looking at the Dispatcher Source code for Invoke, it seems to call…
TheGeneral
  • 79,002
  • 9
  • 103
  • 141
2
votes
1 answer

'Await' not returning to the UI thread when logging with log4net

I have a WPF-MVVM-application. I want to use async and await to make my UI responsive while loading and processing a file. I am getting an exception 'The calling thread cannot access this object because a different thread owns it' when a method…
Timitry
  • 2,646
  • 20
  • 26
2
votes
3 answers

UI will be blocked while using async and await in c#

Here I need to export some data from a local server into Excel. I am using an async call for that method. But still, it is blocking the UI while exporting the data. May I know the reason why the UI is being blocking? Also, I need some…
Pandi
  • 471
  • 3
  • 17
2
votes
4 answers

Will Runnables block the UI thread?

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…
Boby
  • 856
  • 7
  • 9
2
votes
1 answer

Does fragment onStop run on UI thread

I have some fragments loaded in a ViewPager, where each "page" is loaded from a row in a cursor. Each fragment shows an image (JPEG) on the device. When the user dismisses the fragment (i.e swipe/page change, hits back/up, or just closes the app…
joakimk
  • 822
  • 9
  • 26
2
votes
1 answer

Listening UI Events on MainThread(UI Thread) and what view that triggers the event

is there anyway to listen on UIevents such as button click on main/ui thread? without interacting directly on each UI's callbacks(e.g onClickListener) ? I just want to listen to any thing it fires from ui events, I've been digging around but I only…
Robert
  • 141
  • 1
  • 13
2
votes
2 answers

Wait screen during rendering UIElement in WPF

I have a WPF application using PRISM. I have a login screen and on successfuly logging in a new view containing a TileListView with many items appears. This needs over 10 seconds to render because control has to calculate a lot etc. All this uses…
Michi-2142
  • 1,170
  • 3
  • 18
  • 39
2
votes
2 answers

Android startactivity freezes the app

I made very simple app. Basically I have activity A that starts activity B if button is pressed. So here's the code openMapFAB.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { …
David
  • 3,055
  • 4
  • 30
  • 73
2
votes
1 answer

Override Image.prototype by using webworker

it is possible to overwrite the charging method of an image so that this loading is done by a WebWorker? Example: Image.prototype.contructor = function(arguments){ // Webworker implementation } //or Image.prototype.setSrc = function(arguments){ …
1fabiopereira
  • 542
  • 2
  • 4
  • 18
2
votes
2 answers

Fatal Exception:Async Task java.lang.OutOfMemoryError in doInBackground() method in Android?

I have a Linear layout two which I am adding Image View's programmatically.I am using imageView.setImageBitmap(bitmap); to set the image. And I get a Out of Memory Error. After reading through…
AndroidNewBee
  • 744
  • 3
  • 12
  • 36
2
votes
2 answers

Thread in Android method onCreate() still stops the UiThread in 10% of the cases

This is my onCreate method of my first activity of my app. It initalizes all Widgets and then starts a Thread to load model data from the internet. In some cases, when the network is really slow or not responding, the "initializeModelThread" seems…
OneWorld
  • 17,512
  • 21
  • 86
  • 136
2
votes
3 answers

Posting to UI thread

I would like to create a new thread in onCreate and communicate with the UI thread using post on a View. However, the posted statements never seem to be run. Here's a small example: import android.app.Activity import android.os.Bundle import…
Cactus
  • 27,075
  • 9
  • 69
  • 149