Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Background thread vs UI thread

Could any one help me to figure out background thread and UI thread in C#.I have googled it but i coudnt find article illustrate both.

like image 243
Renushi Avatar asked Mar 29 '11 11:03

Renushi


People also ask

What is UI thread and background thread?

Main Thread: The default, primary thread created anytime an Android application is launched. Also known as a UI thread, it is in charge of handling all user interface and activities, unless otherwise specified. Runnable is an interface meant to handle sharing code between threads. It contains only one method: run() .

What is background thread?

Background threads are identical to foreground threads with one exception: a background thread does not keep the managed execution environment running. Once all foreground threads have been stopped in a managed process (where the .exe file is a managed assembly), the system stops all background threads and shuts down.

What is an UI thread?

User Interface Thread or UI-Thread in Android is a Thread element responsible for updating the layout elements of the application implicitly or explicitly. This means, to update an element or change its attributes in the application layout ie the front-end of the application, one can make use of the UI-Thread.

What is main thread and background thread in Android?

For example, if your app makes a network request from the main thread, your app's UI is frozen until it receives the network response. You can create additional background threads to handle long-running operations while the main thread continues to handle UI updates.


1 Answers

A UI thread creates UI elements and waits and responds to events like mouse clicks and key presses. You can only access the UI elements from the UI thread.

There are two types of threads: background and foreground. A UI thread is an example of a foreground thread.

The difference between background and foreground threads is pretty simple. Background threads don't stop a process from terminating, but foreground threads do. When the last foreground thread stops, then all the background threads are also stopped and the process ends.

like image 192
Arsen Mkrtchyan Avatar answered Oct 05 '22 01:10

Arsen Mkrtchyan