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

SabineWo-8318 116 Reputation points

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
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
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.


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

2 additional answers

Sort by: Most helpful
  1. Duane Arnold 3,216 Reputation points

    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

    @Duane Arnold
    Thanks you anyway!

    0 comments No comments