Task never ends in Windows Form App (vb.net Framework 4.8)

SabineWo-8318 116 Reputation points
2021-01-25T14:34:31.783+00:00

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

Universal Windows Platform (UWP)
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,668 questions
0 comments No comments
{count} votes

2 additional answers

Sort by: Most helpful
  1. 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?

    0 comments No comments

  2. SabineWo-8318 116 Reputation points
    2021-01-25T17:10:04.66+00:00

    @Duane Arnold
    Thanks you anyway!

    0 comments No comments