Convert async Task from c to vb net

0 votes

I'm using a C# to VB.NET converter to attempt and convert this code, however there are several errors.

private async Task OnRequestBlockResourceEventHandler(object sender, SessionEventArgs e)
            => await Task.Run(
                () =>
                {
                    if (e.HttpClient.Request.RequestUri.ToString().Contains("analytics"))
                    {
                        string customBody = string.Empty;
                        e.Ok(Encoding.UTF8.GetBytes(customBody));
                    }
                });

and the VB.NET code conversion is here:

Private Async Function OnRequestBlockResourceEventHandler(ByVal sender As Object, ByVal e As SessionEventArgs) As Task
    Return Await Task.Run(Function()

                              If e.HttpClient.Request.RequestUri.ToString().Contains("analytics") Then
                                  Dim customBody As String = String.Empty
                                  e.Ok(Encoding.UTF8.GetBytes(customBody))
                              End If
                          End Function)
End Function

The error shows this

Comma, ')', or a valid expression continuation expected.

'Return' statements in this Async method cannot return a value since
the return type of the function is 'Task'. Consider changing the
function's return type to 'Task(Of T)'
Dec 12, 2022 in C# by Roshan
• 300 points
1,614 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In C#

0 votes
0 answers

How Convert VB Project to C#

I have a VB project that has ...READ MORE

Jun 11, 2022 in C# by jyoti
• 1,240 points
742 views
0 votes
0 answers

Roslyn: Convert C# to VB

I have a situation where I need ...READ MORE

Dec 12, 2022 in C# by Roshan
• 300 points
519 views
0 votes
0 answers

Convert VB.NET --> C# Projects

Can someone suggest a suitable program that ...READ MORE

Dec 12, 2022 in C# by Roshan
• 300 points
642 views
0 votes
1 answer

How to convert JSON text into objects using C#

To make a class out of a ...READ MORE

answered Jun 13, 2022 in C# by krishna
• 2,820 points
574 views
0 votes
1 answer

How to send email in ASP.NET C#

You can try this using Hotmail like ...READ MORE

answered Jun 14, 2022 in C# by krishna
• 2,820 points
960 views
0 votes
1 answer

Questions every good .NET developer should be able to answer?

If I were interviewing someone who knew ...READ MORE

answered May 30, 2022 in C# by rajiv
• 1,620 points
803 views
0 votes
0 answers

Adding the CANONICAL tag to my page for SEO through code behind?

I am using ASP.NET with MasterPages. Thus ...READ MORE

Mar 3, 2022 in Digital Marketing by Kichu
• 19,040 points
1,358 views
0 votes
1 answer

Convert VB.NET --> C# Projects

You may decompile whole Assemblies into Visual ...READ MORE

answered May 30, 2022 in C# by rajiv
• 1,620 points
638 views
0 votes
1 answer

What is the best C# to VB.net converter

Telerik has a solid SharpDevelop-based converter that ...READ MORE

answered May 30, 2022 in C# by rajiv
• 1,620 points
1,607 views
0 votes
1 answer

Convert VB.NET --> C# Projects

You may decompile whole Assemblies into Visual ...READ MORE

answered May 31, 2022 in C# by anonymous
784 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP