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
4
votes
3 answers

Image changing in ImageView periodically . . .

package com.example.imagechange; public class MainActivity extends Activity { ImageView imageView; int []imageArray={R.drawable.a0,R.drawable.a1,R.drawable.a2,R.drawable.a3}; @Override public void onCreate(Bundle savedInstanceState) { …
4
votes
3 answers

When BroadcastReceiver runs, which thread is it running on, system wide or only your applications?

I have an Alarm go of using BroadcastReceiver, but I am a little confused on Threads. I would like to have it run on a separate thread so it doesn't cause unresponsiveness to anything else, but when looking on the Android Docs, I still don't really…
Andy
  • 10,553
  • 21
  • 75
  • 125
4
votes
3 answers

Visual Basic.NET: how to create a thread to update the UI

The usual VB way to handle a computationally heavy task is to put it in a background worker thread, while the main thread keeps handling the UI. Say for whatever reason I needed to do this the other way around: the main thread doing the grunt work…
3
votes
6 answers

BackgroundWorker returns to wrong thread

In my application, I create a new UI-Thread with the fallowing code: Thread thread = new Thread(() => { MyWindow windowInAnotherThread = new MyWindow(); windowInAnotherThread.Show(); …
BennoDual
  • 5,865
  • 15
  • 67
  • 153
3
votes
2 answers

Avoiding the window (WPF) to freeze while using TPL

I am building a WPF which has a button that execute a sql query in sql server (the query could take a long time to run). I want to use TPL for doing that. This code: var result = Task.Factory.StartNew(() => { command.ExecuteNonQuery(); }); gives…
Aharon Muallem
  • 1,143
  • 3
  • 13
  • 20
3
votes
1 answer

How to move to UI thread in .Net Core 3.1?

In my WPF .Net Core application I receive messages from a message bus and need to assign the message data to properties that bind to my WPF frontend and hence need to move the incoming messages onto the UI thread. So far in .Net Framework 4.7.2 I…
Matt
  • 7,004
  • 11
  • 71
  • 117
3
votes
3 answers

Handling UI from other thread

I have a class which extends the Runnable. This class performs some heavy operation (basically downloads the image from network) in different thread. I want to update the UI (display the downloaded image to an ImageView) from this class. I have…
Vinod Maurya
  • 4,167
  • 11
  • 50
  • 81
3
votes
2 answers

Silverlight UI Thread Freezing

I have a grid control that is trying to display large amounts of data and so it takes a long time to render on the UI thread. I have added a loading bar that animates and displays depending on if the screen is busy or not (is rendering). However…
Matthew Bill
  • 203
  • 3
  • 11
3
votes
2 answers

Does databinding always marshal to the UI thread?

When binding to a property in Silverlight 3 and 4, the Windows Phone 7 version silverlight and in WPF 3.5 and 4 will property change notifications always be marshalled to the UI thread? Are you aware of any scenario where I can not rely on that and…
bitbonk
  • 48,890
  • 37
  • 186
  • 278
3
votes
2 answers

SQLite query run on UI thread with ExpandableListView/SimpleCursorTreeAdapter

I'm in the progress of developing an Android app for displaying a number of RSS feeds (yes, I know there are many apps like this already). The data to be displayed is backed by a content provider, and I want to be backward compatible with API level…
jacob11
  • 670
  • 1
  • 9
  • 12
3
votes
1 answer

Immediately update UI when OnClick_Event occurs

Very simple example: Code behind: public partial class ItemsPage : ContentPage { private ViewModels.ItemsViewModel _viewModel; public…
broadband
  • 3,266
  • 6
  • 43
  • 73
3
votes
4 answers

RecyclerView blocking ui thread during updates

There are more than 200 items in my list. RecyclerView is updated regularly (Every 10 seconds) . RecyclerView blocking ui thread for few seconds during updates. I'm using notifyDataSetChanged method for refresh recyclerview. Is there another way…
3
votes
2 answers

RxJava onBackpressureBuffer not emitting items

I've witnessed a weird behavior with onBackpressureBuffer, I'm not sure if it is a valid behavior or a bug. I'm having a tcp call that is emitting items in a certain rate (using streaming and inputStream but that just for some info) On top of it…
ndori
  • 1,934
  • 1
  • 18
  • 23
3
votes
1 answer

Invoking Method on UI thread from within a Lock() with .Net 4.0

I have the same problem as this person had. However the question was answered by using .Net 4.5, but I only have .Net 4.0. So I created my own asynchronous semaphore based on this tutorial and implemented my code based on additional comments of the…
gartenriese
  • 4,131
  • 6
  • 36
  • 60
3
votes
1 answer

Can I simulate or somehow create a WPF UI thread within a Console Application or Class Library?

I have to use an external API that for whatever reason only works as long as it is initialized and run on a WPF app's UI thread. If I spin up a task/thread that does not use the UI Synchonization Context even within a WPF test app the API does not…
Matt
  • 7,004
  • 11
  • 71
  • 117