From the course: Threading in C#
Unlock the full course today
Join today to access over 22,500 courses taught by industry experts or purchase this course individually.
Exception handling
- [Instructor] When we do multi-threading one of the most important things is to understand how exception handling works when it comes to threading. Again, we're going to start a new project, call it exceptions, and let's create a method called demo. We can resolve it using control dot and now we have a method right here and we can use our try catch statement, very standard try catch statement as you've been using in C# projects. So I'm going to have to throw some kind of exception to make sure that there is an exception that gets thrown. So in this case we're hacking the system to create an exception, I'm going to call execute and all I'm going to do in execute is throw a null so I have a null pointer exception thrown to me. Once I do that I'm going to call that method right here. Now ideally what we would expect is for the exception to throw in right here. And one of the simple ways to call this is say console dot write line. And now I can say anything in exception dot even tostring…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.