Hi
Please tell vb.net equivalent of following method:

private void LookForUpdates()
        {
            System.Threading.ThreadStart timerThreadStart = new System.Threading.ThreadStart(delegate()
            {

                sua = new ShowUpdatAvailable();
                DelGetUpdateArgs delGetUpdateArgs = new DelGetUpdateArgs(this.GetUpdateArgs);
                sua.GetUpdateArgs = delGetUpdateArgs;
                sua.StartLookingForUpdate();

            });

            timerThread = new System.Threading.Thread(timerThreadStart);
            timerThread.Start();
        }

I tried using C# to VB.NET code converter which gave me this:

Private Sub LookForUpdates()
            Dim timerThreadStart As New System.Threading.ThreadStart(Function() Do

        sua = New My.ShowUpdatAvailable()
        Dim delGetUpdateArgs As New DelGetUpdateArgs(AddressOf Me.GetUpdateArgs)
        sua.GetUpdateArgs = delGetUpdateArgs

        sua.StartLookingForUpdate()
            End Function)

            timerThread = New System.Threading.Thread(timerThreadStart)
            timerThread.Start()
        End Sub

Which on build in visual studio 2005 gives an error.

Please help

Recommended Answers

All 2 Replies

VB.NET doesn't support anonymous delegates like C# does. Just break the code out to another function:

Private Sub LookForUpdates()
		Dim timerThreadStart As New System.Threading.ThreadStart(AddressOf LookForUpdatesDelegate)
		Dim timerThread As New System.Threading.Thread(timerThreadStart)
		timerThread.Start()
	End Sub

	Private Sub LookForUpdatesDelegate()
		sua = New My.ShowUpdatAvailable()
		Dim delGetUpdateArgs As New DelGetUpdateArgs(AddressOf Me.GetUpdateArgs)
		sua.GetUpdateArgs = delGetUpdateArgs
		sua.StartLookingForUpdate()
	End Sub

Thanks Sknake this is the way i did finally.

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.