Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pass parameter to Thread C# to VB

Status
Not open for further replies.

cappmgr

Programmer
Jan 29, 2003
639
US
This works passing iSleepdelay in the constructor to make a new thread sleep. I have not been able to get a VB version working.
Code:
	public class Sleep
	{
		private Int32 _iSleepDelay;
		public Sleep(Int32 iSleepDelay)
		{
			this._iSleepDelay = iSleepDelay;
		}

		public void Start() 
		{
			new Thread(new ThreadStart(ThreadSleep)).Start();
		}

		public void ThreadSleep()
		{
			System.Threading.Thread.Sleep(_iSleepDelay * 1000);
		}
	}
the to make it sleep
Code:
new Sleep(iSleepDelay).Start();
The online code convertors didn't help.
Any help appreciated in converting this to VB.NET
Thank you,
Marty
 
Here's what I came up with it works,
Code:
Public Class Sleep
    Dim sleepDelay As Int32
    Public Sub New(ByVal sleepDelay As Int32)
        Me.sleepDelay = sleepDelay
    End Sub
    Public Sub ThreadSleep()
        System.Threading.Thread.Sleep(sleepDelay * 1000)
    End Sub
End Class
and to call it
Code:
Dim ts As New Sleep(iSleepDelay)
Dim t As New Thread(AddressOf ts.ThreadSleep)
t.Start()
t.Join()
Marty
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top