Chapter 7: Multithreading and Asynchronous Processing Flashcards

1
Q

Name some threads that all .net applications have.

A

Garbage Collector Thread

Finalizer thread

Main thread

UI Thread

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

TPL stands for

A

Task Parallel Library

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

A .net application ends when all of the following kind of threads stop executing.

A

nonbackground.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the difference between many core and multi-core?

A

Multi-Cor has more than one core that are all the same type.

Many core can have more than one of different type.s

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Disadvantages of multithreaded applications

A

1) Resource intensive (1 MB of memory per thread, overhead of scheduler swtiching between threads)
2) creation and destroying threads takes time.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Method that causes current thread to wait on another

A

Join()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Differences between manually created threads and thread pool threads

A

all threads from the ThreadPool are background threads

you can’t abort or interrupt a ThreadPool thread.

you can’t join a thread from the ThreadPool

Threads are reused from the threadppol

can’t control priority of threads from the ThreadPool

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

technologies built on top of ThreadPool

A

Task Parallel Library (TPL)

Asynchronous Pattern Model (APM)

Event-based Asynchronous Pattern (EPA)

Task-based Asynchronous Pattern Model (TAP)

new async/await keywords

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Events of the Background worker class

A

DoWork (e.Result to hold the result)

RunWorkerCompleted

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

TPL: ways to create a task (there are 4)

A

1) create an instance and call start()
2) static TaskFactory.StartNew
3) static Task.Run
4) Task continuation methods: Task.WhenAll, Task.WhenAny, TaskFactory.ContinueWhenAll, TaskFactory.ContinueWhenAny

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Hyperthreading

A

means that every core has two intruction pipelines, but only one execution engine.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What was the only reason to use the TaskScheduler (given by the book)?

A

To force a task to be done by the current UI thread. TaskScheduler.FromCurrentSynchronizationContext().

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

the three static methods of the Parallel class

A

For

ForEach

Invoke

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Three Continuation methods from Task and Task.Factory

A

Task.ContinueWith

Task.Factory.ContinueWhenAll

Task.Factory.ContinueWhenAny

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

the compiler generates a warning if your method marked async is missing what?

A

an await statement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Synchronization events (there are two)

A

EventWaitHandle (Set state as signalled)

CounDownEvent ()

17
Q

Barriers? No Idea, the example sucked and I need to stufy this more.

A

nuff said.

18
Q

Instead of using simple lock (object) this is a more primative version.

A

Monitor.Enter(object)

Monitor.Exit(object)

19
Q

The only lock free alternative described by the book

A

interlocked

20
Q

this should be avoided at all costs (locking)

A

lock.this()

21
Q

concurrent collections

A

BlockingCollection<t></t>

ConcurrentBag<t></t>

ConcurrentDictionary<tkey></tkey>

ConcurrentQueue<t></t>

ConcurrentStack<t></t>

22
Q

Cancellation

(Two major players)

A

CacellationTokenSource (class)

CancellationToken (struct)