TPL Break on unhandled exceptions

I am using async await as well as Task.Factory.StartNew in my application but one thing that i noticed changed is that visual studio is no more breaking when an unhandled exception occured

Here is what i mean by before using await

but after i turn a method into a Task and use await

It is only captured in the output area in visual studio...

BTW : It is very strange for me as i am new to .Net4.5 please excuse me if failed to illustrate what i need specifically but again what i want to know is

  • How could i make visual studio break on the exceptions when using async await


When the debugger says "Exception was unhandled by user code", what it means is that an exception has propagated up to the framework. Since an async Task method places its exceptions on its returned Task, the exception does not propagate to the framework. An exception like this is unobserved.

If you want the debugger to break when exceptions are thrown, then use Debugger -> Exceptions -> Check the "Thrown" box for CLR Exceptions.

If you want to observe the exception, then change from TaskFactory.StartNew to Task.Run and call Wait on the returned Task. This will propagate the exception (wrapped in an AggregateException) through Main and up to the framework.

Need Your Help

Is there an easy way to revert a forecast back into a time series for plotting?

r plot forecasting

I am new to R and have found this site extremely helpful, so this covers the second half of my question (one issue per post). Thank you for your assistance ahead of time.

.net mvc email as username returning error - InvalidProviderUserKey

.net model-view-controller createuser

I have a .Net MVC application that I am trying to use an email address as the username. I implemented the logic from this article where the username is masked as the email. However, when I try to c...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.