From the course: Threading in C#
Unlock the full course today
Join today to access over 24,900 courses taught by industry experts.
Exception handling - C# Tutorial
From the course: Threading in C#
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.
Contents
-
-
-
Understanding threading2m 55s
-
(Locked)
Context switching7m 12s
-
(Locked)
Thread naming2m 33s
-
(Locked)
Shared resources2m 52s
-
(Locked)
Shared resources demo7m 35s
-
(Locked)
Threads vs. processes1m 1s
-
(Locked)
Local memory2m 50s
-
(Locked)
Thread pool2m 41s
-
(Locked)
Thread pool demo9m 49s
-
(Locked)
Other threading concepts3m 27s
-
(Locked)
Exception handling4m 37s
-
-
-
-