From the course: Threading in C#

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Tasks with IO

Tasks with IO - C# Tutorial

From the course: Threading in C#

Start my 1-month free trial

Tasks with IO

- [Instructor] Now that we're familiar with how to use tasks, let's look into an example that demonstrates how to use tasks for I/O bound operations. This time, I'm going to use a different way to create a task, we're going to use task factory, which is very simple as Task.Factory.startNew. We can do a task of type string, which by default it is of type string so you may not notice a big difference if the return type is a string. But just to make it explicit, I like to add the type right there. So if you're using a tool like ReSharper, it might actually tell you that you don't need to use a string. So what I like to do is get some posts from a link that I like to use when I'm working with json. So, it's jsonplaceholder.typicode.com /posts. So if I were to click this link, you can see, it's got about 100 different posts that it will return if I make this call. Just got a user ID 10, ID is 100, and then there's a title, and then there's a body. It's a very simple payload, and all you…

Contents