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

How to make timer task to wait till runOnUiThread completed

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() { …
Adil Bhatty
  • 17,190
  • 34
  • 81
  • 118
2
votes
3 answers

Multiple Swing event-dispatch threads

I would like to create a new event-dispatch thread in Swing, and I'm having trouble finding any references online for how to do this. I have done this in .NET by creating a new thread and calling Application.run(...). Has anyone done this? Is it…
dcstraw
  • 3,243
  • 3
  • 29
  • 38
2
votes
1 answer

InvokeOnMainThread() not necessarily invoking on main thread - bug or feature?

I'm using a Timer and let it perform regular checks. If the test condition is true, I start a thread and let it do what it has to do. If within that thread I want to change the UI I'm using InvokeOnMainThread(). But as the thread was triggered from…
Krumelur
  • 32,180
  • 27
  • 124
  • 263
2
votes
2 answers

how to indicate to main UI thread when background task has completed? (performSelectorInBackground)

How can I get an indication to main UI thread in an iPhone app IOS program, when background task has completed? Background I'm trying to setup a loading indicator per the concept at How to add a UIActivityIndicator to a splash screen in a iphone…
Greg
  • 34,042
  • 79
  • 253
  • 454
2
votes
3 answers

Why cant a thread that is not the UI thread access the view?

I know that no thread can access the current view unless it is the UI Thread. I am wondering why? Why does it matter which thread is changing the view? Is it a security reason? This is the work around I use: public void doLayout() { …
gsfd
  • 1,070
  • 2
  • 12
  • 17
2
votes
1 answer

Is Main/UI Thread same as System UI Thread in Android?

This question is different than what's being discussed about Main thread and UI thread in Android. By mean of System thread - the thread which handles system UI like statusbar, notifications & other ongoing system processes, say thread which handles…
2
votes
0 answers

Debugging of the console application ended without waiting for the process created under to finish

When I run a C# console application, it creates a parallel process; now, my main application threads must wait until the process created under it is closed; however, in my case, the main ui thread exited when the process start code was executed; it…
max
  • 255
  • 2
  • 7
2
votes
2 answers

UI thread access outside control

I have a Session object that manages object states (similar to a nhibernate session). This session listens to events from an external source that may require updates to the internal session state. We've tried implementing locking in the session to…
Mike Q
  • 22,839
  • 20
  • 87
  • 129
2
votes
0 answers

Can this Runnable cause a memory leak, when app is closed?

I have this piece of code in my onViewCreated to request focus on my EditText . someEditText.apply { post { requestFocus() } } Let's say that the app is closed before that Runnable completes. Is it possible to create a memory leak in such scenario…
2
votes
3 answers

Processing Windows Messages in blocked UI Thread?

This is possibly related to ProgressBar updates in blocked UI thread but is a little different. While troubleshooting a crashing WinForms control (a DevExpress treelist) a member of our team encountered an unusual situation, and I'm wondering if…
dhochee
  • 412
  • 4
  • 11
2
votes
0 answers

How does an animation work on UI thread without blocking other messages and runnable in message queue of UI Thread?

I am working on some old android code where the code looks something like this: public void TestMethod() { // handler posting on main thread handler.post(() -> { //Invokes method(); }); animation.addListener(new…
imvishi
  • 233
  • 4
  • 18
2
votes
0 answers

Cancelling Flutters compute function from ui

I have a function that uses the compute method to process some functionality and not lock the ui thread up. This works fine but I would like to give the user the option to cancel the processing. Is there a method of cancelling the compute function,…
ebg11
  • 906
  • 1
  • 12
  • 33
2
votes
1 answer

Why does Android service needs to run on UI thread?

I have a probably simple question. I have an android service; where in I have created a generic service class which requests locks and executes actual (extending) service code in a separate thread. Example below: abstract public class ParentService…
Priyank
  • 14,231
  • 18
  • 78
  • 107
2
votes
2 answers

Why does the UI freeze when dismissing ViewController with ARSCNView?

I am running an ARKit Session where I place SceneKit nodes. With every node I am instantiating a new view controller and pass its view as the node's content like so: func createTextNode(anchor: ARCardAnchor) -> SCNNode? { let plane =…
Sebastian
  • 445
  • 5
  • 20
2
votes
2 answers

Blank components in a Form while updating it from a thread

I have made a Form that moves across the screen to the left, but all of the components on the Form are blank. I put the code for the movement in comments and everything was fine, so the problem is in my movement code, but I don't know what the…
Hamez
  • 33
  • 4