Questions tagged [background-thread]

A background thread is a thread that not directly driving the application but does some processing asynchronously.

Many UI toolkits require the use of background threads for anything that takes longer than a couple of milliseconds in order to keep the UI responsive.

Background threads are referred to as daemon threads at times.

Often background threads take care of recurring tasks, like cleaning up caches or similar.

Since the term 'background thread' is not very specific you might want to consider more specific tags related to the actual technology you are using.

If your question is independent of the actual technology this tag is a good fit.

Background Thread in .Net
Background thread in java

224 questions
319
votes
21 answers

Getting a "This application is modifying the autolayout engine from a background thread" error?

Been encountering this error a lot in my OS X using swift: "This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes. This will cause an exception in a future release." I…
Mark
  • 12,359
  • 5
  • 21
  • 37
110
votes
5 answers

Proper use of beginBackgroundTaskWithExpirationHandler

I'm a bit confused about how and when to use beginBackgroundTaskWithExpirationHandler. Apple shows in their examples to use it in applicationDidEnterBackground delegate, to get more time to complete some important task, usually a network…
Eyal
  • 10,777
  • 18
  • 78
  • 130
107
votes
13 answers

How to run certain task every day at a particular time using ScheduledExecutorService?

I am trying to run a certain task everyday at 5 AM in the morning. So I decided to use ScheduledExecutorService for this but so far I have seen examples which shows how to run task every few minutes. And I am not able to find any example which…
AKIWEB
  • 19,008
  • 67
  • 180
  • 294
79
votes
5 answers

How to always run a service in the background?

I am in the process of creating an app that is similar to the built-in SMS app. What I need: a service that is always running in the background every 5 min. the service checks the current location of the device and calls a web service if…
Thomas H
  • 791
  • 1
  • 6
  • 3
23
votes
8 answers

Kotlin: How to delay code in Android without making the UI freeze

I am trying to delay code in Kotlin I have tried Thread.sleep(1000) But its freezes the UI. Does somebody know why this is happening And how to delay without freezing the UI?
asaf
  • 351
  • 1
  • 3
  • 9
23
votes
2 answers

How to run cordova plugins in the background?

Im making an application based on phonegap (cordova). I have tested it some times, and lately I saw a message in xcode that said "Plugin should use a background thread." So is it possible to make cordova plugins run in the background of the app? if…
20
votes
6 answers

Django Background Task

I need to populate a SQLite database every few minutes in Django, but I want to serve stale data until the data is available for the database to be updated. (i.e. I don't want to block for the data to be gathered; the only time I can block is if…
user541686
  • 205,094
  • 128
  • 528
  • 886
18
votes
2 answers

Does react-native support Multithreading and Background threading or Parallel Execution? How can we do that?

I have gone through the official documentation of react-native and some other medium sources and blogs, I came to know that there is UI Thread and JavaScript Thread in react-native. Javascript thread is the thread where the logic will run javascript…
17
votes
0 answers

BackgroundTask iOS 13 Swift

I want to run the function in the background. But I get an error. The error I received is "nw_connection_receive_internal_block_invoke. Why am I getting this problem? I'm trying it on an iOS 13 device. But I can't run the application in the…
13
votes
2 answers

Cordova shows an warning as " THREAD WARNING: [Your function] took [n] ms. " in iOS

"THREAD WARNING: ['Console'] took '81.661865' ms. Plugin should use a background thread." While running iOS Phonegap project. Similarly for some of the remaining plugins like geolocation and filesystem. As I am new to Phonegap ,can please anyone…
soumya
  • 3,801
  • 9
  • 35
  • 69
10
votes
1 answer

Flutter: How can I run a function on background thread in dart

Future getImage() async { var image = await ImagePicker.pickImage(source: ImageSource.camera); setState(() { _image = image; print("IMG:" + _image.toString()); }); setPrefs() ; } Future setPrefs() async { _base64 =…
krishnakumarcn
  • 3,959
  • 6
  • 39
  • 69
9
votes
1 answer

android addView in background thread

I need to add lots of views in a loop, while this fragment does that, the app will also have a navigation drawer and action bar where the user can do things. so I would like this process to not a) slow down the app by blocking the user, b)…
CQM
  • 42,592
  • 75
  • 224
  • 366
8
votes
2 answers

Updating Views from non-UI threads

I am confused about how the Android system works, specially when it updates the view hierarchy. We all know that we should not update any view from any thread other than UI (Main) thread. And even Android system throws exception when we try to do…
7
votes
2 answers

How to create custom icons for QFileSystemModel in a background thread

I am making a file browser in qt for some custom design-files. I want to load their preview as their thumbnail and for that reason I am using QIconProvider to return the Icon to my QFileSystemModel. The problem is that the algorithm that creates the…
willy
  • 487
  • 5
  • 21
7
votes
2 answers

Is it OK to create a UIViewController on a background thread?

Related: Is it ok to create a UIView on a background thread? Is this background-thread code safe? let viewController = MyViewController(nibName: nil, bundle: nil) viewController.title = "My Title" viewController.myProperty =…
ma11hew28
  • 121,420
  • 116
  • 450
  • 651
1
2 3
14 15