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

Does AsynckTask.onPostExecute and FragmentActivity.onResumeFragments run on same thread (ui thread)?

I get ConcurrentModificationException when I traverse the ArrayList. What I did: 1. activity has a ArrayList 2. add Callable to ArrayList when AsyncTask.onPostExecute 3. traverse the ArrayList to call the callable in…
2
votes
1 answer

Are onTouch(), onClick() running sequentially in the same thread?

Are onTouch(), onClick(), runOnUiThread() running in the same UI thread sequentially? Or do I have to worry about synchronization issues among them?
user256239
  • 17,717
  • 26
  • 77
  • 89
2
votes
2 answers

Accessing UI Thread from Async Thread

Quick question: I have been using frameworks that spawn worker threads to perform asynchronous tasks, a good example is Retrofit. Within the success/failure sections, I may pop up a Dialog box which would need to be on the UI thread. I have been…
Perry Hoekstra
  • 2,687
  • 3
  • 33
  • 52
2
votes
0 answers

Let ScheduledThreadPoolExecutor execute tasks on UI thread

How can I use a ScheduledThreadPoolExecutor and schedule a task which is always executed on the UI thread? Currently, I do the following mScheduledTask = sBackgroundExecutor.scheduleAtFixedRate(new Runnable() { @Override public…
Mahoni
  • 7,088
  • 17
  • 58
  • 115
2
votes
3 answers

How to check every 30seconds with dispatchertimer without affect the UI in c#?

I hav tried the below code for checking reports from server in every 30seconds,but after 30seconds tick,The application hangs for several seconds.How to avoid the Hanging problem. The below code am tried,what change want to given in…
NvadeepKumar
  • 25
  • 1
  • 7
2
votes
1 answer

Holding event fired twice windows phone 8.1

I have a holding event on a ListBoxItem. So When I hold an item, it enters right in the function but it appears as it's fired twice. private async void OutersAndContactInTel_Holding(object sender, HoldingRoutedEventArgs e) { try { …
Hubert Solecki
  • 2,611
  • 5
  • 31
  • 63
2
votes
1 answer

Update ImageView's bitmap using UI-Thread

I have to manipulate pixels of a bitmap every one second, during another operation, and show the result in ImageView. This is a method that manipulates bitmap and updates ImageView: private void overlay(Bitmap bitmap) { int j = 70; while (flag) { …
2
votes
1 answer

UI freezes when using SystemEvents.UserPreferenceChanged and multiple UI threads

In my C# Windows Forms application there are two threads: Main Thread (Program.cs) WorkerClass Thread (STA-Apartment). When there is long running Task, it freeze/stuck the entire process and No exception or notification fired..it hangs…
Viral
  • 363
  • 2
  • 4
  • 14
2
votes
0 answers

Android convention to denote method UI thread safety

Android documentation, tutorials, videos and the like are filled with best practice on how to avoid non-essential processing on the UI thread. However, when creating a big app or using external components it can be hard to remember which methods…
Jim Vitek
  • 4,174
  • 3
  • 23
  • 32
2
votes
3 answers

UI Thread and Image processing

I have a thread with a priority set to Thread.MIN_PRIORITY + 1 that does some image processing for me (resizing, reading and writing). I've noticed that whenever that thread is working on an image, animations in my UI thread start to stutter and…
Nyx
  • 2,233
  • 1
  • 12
  • 25
2
votes
1 answer

JUnit test on android app with cache and ArrayAdapter

// use case 10b alternate version // caches a read comment temporarily public void testCacheReadComment2() throws Throwable{ runTestOnUiThread(new Runnable() { @Override public void run(){ CommentBuilder…
2
votes
1 answer

Android updating ui thread elements - best practice?

I have an app that shows some measurement values like temperature, speed and so on. I want to stick more or less to the MVC pattern so I got something that receives the values when they appear (from a bluetooth component) and sorts them to the…
Ginbak
  • 105
  • 9
2
votes
4 answers

How to send a Message from a seperate thread to the UI thread?

I am trying to find a way to send a message from the a seperate thread to the UI Thread, is that possible? The thread has not been launched from the MainActivity but from a service, does it make any difference. Thanks in advance for you help. Here…
user3141990
  • 129
  • 1
  • 7
2
votes
1 answer

With jFace and SWT, is it preferable to have the Gui Thread as the main thread or that does not matter?

More specifically, my application is a network application, a kind of hub in which different endpoint connect and communicate. We need a graphical user interface to monitor the behavior of the participant to the hub, and etc.... Provided of course…
MaatDeamon
  • 9,532
  • 9
  • 60
  • 127
2
votes
0 answers

Setting breakpoints in 2 different threads in android

I want to set breakpoints in UI thread and Background thread. I put a breakpoint at the start of run() method in Background Thread and another break point at variable in UI thread, I want to examine. I set break point property to suspend all. Once I…