Hi...
I need to implement multithreading in vb.net....I need to pass a parameter to the function which will be called by the thread...Can someone help me with this?

Recommended Answers

All 2 Replies

Hi,
you can use ParameterizedThreadStart delegate and overloaded method Thread.Start(object)

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;

namespace MultiThreading
{
    class Program
    {
        static void Main(string[] args)
        {
            ParameterizedThreadStart paramThreadStart = new ParameterizedThreadStart(DoSomeThing);
            Thread newThread = new Thread(paramThreadStart);
            newThread.Start("this is test");
        }

        static private void DoSomeThing(object objParam)
        {
            Console.WriteLine(objParam.ToString());

        }
    }
}

Is this plain VB.NET? or ASP.NET using VB.NET?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.