Avatar of rp
rp
Flag for Portugal asked on

Convert Task C# to vb.net

Hi,

I need convert code snippet c# to vb.net. I used the telerik converter, but it seems that automatic conversion is not possible. Someone can help how to implement a task and receive the result.  
C# code
 public bool SendData(string key, string name, string mytext)
        {

            var mytask = Task.Run(() => Send(key, name, mytext));

            var result = mytask.Result;

            return result;
            
        }

Open in new window


Converted Vb.Net code:

Public Function SendData(ByVal key As String, ByVal name As String, ByVal mytext As String) As Boolean
    Dim task = Task.Run(Function() Send(key, name, mytext))
    Dim result = task.Result
    Return result
End Function

Open in new window


After convert give me an error in task.

best regards
Visual Basic.NETC#

Avatar of undefined
Last Comment
David H.H.Lee

8/22/2022 - Mon
Éric Moreau

which error?

and since VB is not case sensitive, it is always better not to name a variable the same thing as an object (ie task vs Task).
ASKER CERTIFIED SOLUTION
David H.H.Lee

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23