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

  • SEARCH
  • Home
  • 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 8455701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:21:05+00:00 2026-06-10T12:21:05+00:00

I have the following code sample in VB .net 2008 Public Function CheckPathFunction(ByVal path

  • 0

I have the following code sample in VB .net 2008

Public Function CheckPathFunction(ByVal path As String) As Boolean
    Return System.IO.File.Exists(path)
End Function

Public Function PathExists(ByVal path As String, ByVal timeout As Integer) As Boolean
    Dim exists As Boolean = True
    Dim t As New Thread(DirectCast(Function() CheckPathFunction(path), ThreadStart))

    t.Start()

    Dim completed As Boolean = t.Join(timeout)
    If Not completed Then
        exists = False
        t.Abort()
    End If

    Return exists
End Function

Unfortunately I have to work with Vb .net 2005 and net framework 2.0; How can I accomplish the same for VB .net 2005?, VB .net 2005 does not support the syntax corresponding to the code line num. 3:

Function() CheckPathFunction(path)

Please note that the function to call requires a parameter and returns a value


I’ve tried using a delegate as indicated next but does not work

Private Delegate Function CheckPath(ByVal path As String) As Boolean

Public Function CheckPathFunction(ByVal path As String) As Boolean
    Return IO.File.Exists(path)
End Function

Public Function PathExists(ByVal path As String, ByVal timeout As Integer) As Boolean
    Dim checkPathDelegate As New CheckPath(AddressOf CheckPathFunction)

    Dim exists As Boolean = True
    Dim t As New Thread(checkPathDelegate(path))

    t.Start()

    Dim completed As Boolean = t.Join(timeout)
    If Not completed Then
        exists = False
        t.Abort()
    End If

    Return exists
End Function

Thanks

  • 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-06-10T12:21:07+00:00Added an answer on June 10, 2026 at 12:21 pm

    Taking as base structure the code by @eol the final working code is:

     Class KeyValuePair
          Public Path As String
          Public Found As Boolean
     End Class
    
     Public Sub CheckPathFunction(ByVal dataObject As Object)
          dataObject.Found = IO.Directory.Exists(dataObject.Path)
     End Sub
    
     Public Function PathExists(ByVal path As String, ByVal timeout As Integer) As Boolean
          Dim exists As Boolean
    
          Dim data As New KeyValuePair
          data.Path = path
    
          Dim t As New Thread(New ParameterizedThreadStart(AddressOf CheckPathFunction))
          t.Start(data)
    
          Dim completed As Boolean = t.Join(timeout)
          If Not completed Then
               exists = False
               t.Abort()
          Else
               exists = data.Found
          End If
    
          Return exists
     End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following code sample in ASP.NET using (PrincipalContext domainContext = new PrincipalContext(ContextType.Domain)) {
I have the following sample code in a VB.NET console application. It compiles and
I have the following code sample that im trying to wrap my head around
I have the following code sample: float val = 16777216.0F; var badResult = Convert.ToDecimal(val);
I have the following sample code and noticed that if I attempt to use
I have the following sample code which doesn't seem to want to run. import
I am new to Emacs, and I have the following code as a sample.
I have a Dictionary bound to DataGridView by using following sample code. DataGridView bound
I have downloaded sample code from Apple Center.I also have gone through following question:
I have a following simple code: def get(): return [lambda: i for i in

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.