Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6018937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:20:49+00:00 2026-05-23T03:20:49+00:00

I am trying to start a new thread in VB.NET and I’m having syntax

  • 0

I am trying to start a new thread in VB.NET and I’m having syntax problems.

In C# this is how we can do the same task using:

var manualResetEvent = new ManualResetEvent(false);
waitHandles.Add(manualResetEvent);
var taskOne = Task.Factory.StartNew(() => new Thread(TaskToRun).Start(manualResetEvent));
taskOne.Wait();

TaskToRun is a void method with a single object parameter.

All online converters generate VB.NET code similar to this:

Dim manualResetEvent = New ManualResetEvent(False)
waitHandles.Add(manualResetEvent)
Dim taskOne = Task.Factory.StartNew(Function() New Thread(AddressOf TaskToRun).Start(manualResetEvent))
taskOne.Wait()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T03:20:50+00:00Added an answer on May 23, 2026 at 3:20 am

    There is no reason to start a Task that does nothing but launch a Thread. You should just create the Task directly. You should be able to do that in VB via:

    Dim manualResetEvent = New ManualResetEvent(False)
    waitHandles.Add(manualResetEvent)
    Dim taskOne = Task.Factory.StartNew(Function() TaskToRun(manualResetEvent))
    
    taskOne.Wait() ' Blocks until task is complete
    

    If you want to force the Task to use a dedicated thread, you can do so by passing the LongRunning hint. With the default TaskScheduler, this will start the task on a dedicated thread (instead of the ThreadPool).


    For reference, the equivelent C# would be:

    var manualResetEvent = new ManualResetEvent(false);
    waitHandles.Add(manualResetEvent);
    var taskOne = Task.Factory.StartNew(() => TaskToRun(manualResetEvent));
    
    taskOne.Wait();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to start a new ASP.NET Web Application Project using Visual Studio 2008.
I am trying to start a new project (asp.net MVC) and I would like
I am trying to start a service from the command line using net start
I'm trying to start using LINQ and specifically LINQ to SQL but I'm having
I'm trying to use the BackgroundWorker class to start a new thread which loads
Suppose I have this code: static void Main(string[] args) { var thread = new
I am trying to start a new MVC project with tests and I thought
I'm trying to start a program using QProcess (Qt4.4 on vista64bit, developing in MSVC2005).
I have this code i'm trying to convert from C# to VB.net: public object
I'm having some trouble getting cross-thread communication/field-updating working properly in my VB.NET 2010 program.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.