I recently saw several presentations on TPL and asynchronous pattern, so I started a small project for pets to try some things. (Both asynchronous and parallel material)
I noticed that SqlConnection has an OpenAsync () method, so I wanted to try it on hold. As far as I understand, the await keyword tells the compiler to check if the operation is complete and if it does not convert the rest of the code into a continuation task. I also realized that I still have to debug the code. However, I have some problems with this.
I wrote the following simple test code:
Async Sub Gogo() Try Await connection1.OpenAsync() Catch ex As Exception Console.WriteLine(ex) End Try SomeCode() End Sub
What happens when I run this code (console application), I get into the wait statement, but no further. I tried to set breakpoints in both the catch statement and the code specified in the try block. Both are not reached, and the console application just shuts down. I donβt understand what is going on here.
I am using VS2012 update 1, (VB) .Net 4.5. In addition, since I suspected that some error had occurred (which really does not make sense, since the code works when I make it synchronous), I configured app.config to escalate invisible exceptions:
<runtime> <ThrowUnobservedTaskExceptions enabled="true"/> </runtime>
However, so far I have not received any exception. What am I missing? Please, help:)
source share