locked
creating a new thread? RRS feed

  • Question

  •  

    Hello!

    I'm working in VS 2005,

     

    I have the line

    Dim LoadT As Thread

    LoadT = New Thread(AddressOf LoadFile)

    LoadT.Start()

    I get a error that that says Overload Resoultion failed because of 'New", etc.

     

    How do I create a new thread in vs 2005.  LoadFile is a sub procedure.

     

    Thanks!

     

    Rudy

    Friday, December 14, 2007 4:48 PM

Answers

  • As you code sample really didnt provide enough detail - I looked at the help and samples to see what was going on.

     

     

    Thread Class
    http://msdn2.microsoft.com/en-us/library/system.threading.thread.thread.aspx


    With the threadstart constructor being a delegate
    http://msdn2.microsoft.com/en-us/library/xx3ezzs2.aspx


    the second link provides a sample and this works just fine, and I created a


    I also used this to create a me own, which appeared to compile and run without a problem.   Perhaps you can reveal more of a simple scenario which repro's such as this - so we can identify what is occuring.

     

    Code Block

    Imports System.Threading

    Public Class Form1
        Sub LoadFile()

        End Sub

        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim LoadT As Thread
            LoadT = New Thread(AddressOf LoadFile)
            LoadT.Start()
        End Sub
    End Class

     

     



    Friday, December 14, 2007 8:46 PM
  •  

    Depending on what your trying to do, you can use the Background worker to accomplish your task
    Monday, December 17, 2007 2:25 AM

All replies

  • As you code sample really didnt provide enough detail - I looked at the help and samples to see what was going on.

     

     

    Thread Class
    http://msdn2.microsoft.com/en-us/library/system.threading.thread.thread.aspx


    With the threadstart constructor being a delegate
    http://msdn2.microsoft.com/en-us/library/xx3ezzs2.aspx


    the second link provides a sample and this works just fine, and I created a


    I also used this to create a me own, which appeared to compile and run without a problem.   Perhaps you can reveal more of a simple scenario which repro's such as this - so we can identify what is occuring.

     

    Code Block

    Imports System.Threading

    Public Class Form1
        Sub LoadFile()

        End Sub

        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim LoadT As Thread
            LoadT = New Thread(AddressOf LoadFile)
            LoadT.Start()
        End Sub
    End Class

     

     



    Friday, December 14, 2007 8:46 PM
  •  

    Depending on what your trying to do, you can use the Background worker to accomplish your task
    Monday, December 17, 2007 2:25 AM
  • Thanks guys!


    Rudy

     

    Monday, December 17, 2007 10:33 PM