Manage Program Flow - Implement multithreading and asynchronous processing - Using Tasks
6 important questions on Manage Program Flow - Implement multithreading and asynchronous processing - Using Tasks
A task can be use to make your application more .........
How to create a task and immediatly start it?
Task t = Task.Run(() =>
{
for (int x = 0; x < 100; x++)
{
Console.Write(‘Deze tekst wordt nu 100 x afgedrukt in de console’);
}
});
When is Task<T> used?
Task<int> t = Task.Run(() =>
{
return 42;
});
Console.WriteLine(t.Result); // Displays 42
- Higher grades + faster learning
- Never study anything twice
- 100% sure, 100% understanding
What is a Task object?
What is Task.Run?
Example:
Task t = Task.Run(() => {blablabla});
Name the properties of the task class.
Status: Returns the Tasks status
IsCancelled: Returns true if the Task was cancelled
IsCompleted: Returns true if the task is completed succesfully
IsFaulted: Returns true if the task is stopped due to an unhandled exception
Factory: Provides access to TaskFactory class. You can use that to create Tasks
The question on the page originate from the summary of the following study material:
- A unique study and practice tool
- Never study anything twice again
- Get the grades you hope for
- 100% sure, 100% understanding