It seems that the system behaves as expected, i.e. ts.GetTask returns null for inexistent tasks, however the subsequent NullPointerException is intercepted by Debugger. If you press <F5> to continue execution, or start the program without debugging using <Ctrl+F5>, then the catch block will be reached.
You can also uncheck the shown “Break when this exception type is thrown” checkbox (or adjust the settings in menu, Debug, Windows, Exception Settings window). Then this kind of exceptions will not be intercepted by Visual Studio during debugging.
It is probably better to add some ‘if(task==null)’ and display an appropriate message.