我的计划是创建一个保持循环的函数。
该功能永远不会完成
Public Shared Async Function checkNewlines(txt As TextBox) As Task
Do
Await checkNewLinesAloop(txt)
Loop While True
LogEvents("This shouldn't be called")
Dim b = 1
b = b + 1
End Function
这样的事情。
当然
LogEvents("This shouldn't be called")
Dim b = 1
b = b + 1
永远不应该被称为正确吗?
该函数在以下位置调用
Private Async Sub CmdSoundAlarm_Click(sender As Object, e As EventArgs) Handles cmdSoundAlarm.Click
Await startAndStopClickingButton2(sender, Async Function() As Task
Await CoinClass.checkNewlines(TextBox1) ' this one never end
Dim b = 1
End Function)
End Sub
和startAndStopClickingButton2有效
Public Async Function startAndStopClickingButton2(ByVal sender As Object, ByVal SomeSub As System.Func(Of Task)) As Task
startClickingButton(sender)
Await SomeSub.Invoke()
Dim c = 1 ' This one should never be called
stopClickingButton(sender)
End Function
由于某种原因,将执行stopClickingButton(sender)。不应该。
checkNewLines(txt作为TextBox)的编写方式永远不要退出