Hi everybody,
now I understand it. I understand the deadlock in the Windows Form App.
I need a async sub and await to the task
Task never ends in Windows Form App (vb.net Framework 4.8)
Hi everybody,
in a Windows Form App a Task never ends. If I put the same code into a Console App (same Framework Version) it runs well and the task ends.
This is my code:
Imports VCCLWebService
Module Module1
Sub Main()
Dim Url As String = "https://localhost:44339"
Dim username As String = "xv12345"
Dim MyResult = Task.WhenAll(AlleMandanten(Url, username)).Result
Debug.Print(MyResult.ToString())
End Sub
Async Function AlleMandanten(url As String, username As String) As Task(Of Integer)
Dim client = New VCCLWebServiceClient()
Dim mandants = Await client.getMandanten(url, username)
If mandants.Count > 1 Then
Return 1
Else
Return 0
End If
End Function
End Module
Why does the Task ends in a Console App, but not in a Windows Form App?
What is wrong here?
I searched a lot of days in the Internet, but I found nothing, that would help me to solve my Problem.
Has anyone an idea?
(I'm gradeful for every proposal)
Thanks for help and I apologise for my bad english.
Sabine
-
SabineWo-8318 116 Reputation points
2021-01-25T17:06:41.357+00:00
2 additional answers
Sort by: Most helpful
-
Duane Arnold 3,216 Reputation points
2021-01-25T17:03:09.35+00:00 What is the reasoning that you are even using a Task to make a call to a Web service?
-
SabineWo-8318 116 Reputation points
2021-01-25T17:10:04.66+00:00 @Duane Arnold
Thanks you anyway!