Warning in Visual Studio 2012 regarding Async/Await

  • Thread starter Thread starter Michael_____
  • Start date Start date
M

Michael_____

Guest
Dear Community,

I work on a Visual Basic Windows Forms project (.Net Framework 4.5) in Visual Studio 2012 and want to use Asnyc/Await.

I ´ve created a TextBox at runtime and added the handler:

Dim TextBox1 As New System.Windows.Forms.TextBox
AddHandler TextBox1.KeyDown, AddressOf TextBox1_KeyDown

Now I want to set the Async statement into this TextBox1_KeyDown Sub:

Private Async Sub TextBox1_KeyDown(sender As Object, e As KeyEventArgs)

But as soon as I put the Async statement into the Sub Visual Studio gives me the following warning in the "AddressOf TextBox1_KeyDown" code line ("TextBox1_KeyDown" is underlined green):

"The Task returned from this Async Function will be dropped, and any exceptions in it ignored. Consider changing it to an Async Sub so its exceptions are propagated."

It seems that the warning occurs in all of the event Subs.

How can I get rid of this warning? Or is this not really a problem and I can ignore it? Or should I not use Async in Subs? The Async Sub is working but I think it´s not a good idea to ignore the warning.

Thanks for your help in advance!

Michael

Continue reading...
 
Back
Top