title: How to make a very simple asynchronous method call in vb.net
body: <p>I just have a simple vb.net website that need to call a Sub that performs a very long task that works with syncing up some directories in the filesystem (details not important).  </p>
  
  <p>When I call the method, it eventually times out on the website waiting for the sub routine to complete.  However, even though the website times out, the routine eventually completes it's task and all the directories end up as they should.  </p>
  
  <p>I want to just prevent the timeout so I'd like to just call the Sub asynchronously.  I do not need (or even want) and callback/confirmation that it ran successfully.</p>
  
  <p>So, how can I call my method asynchronously inside a website using VB.net?</p>
  
  <p>If you need to some code:</p>
  
  <pre><code>Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
      Call DoAsyncWork()
  End Sub
  
  Protected Sub DoAsyncWork()
          Dim ID As String = ParentAccountID
          Dim ParentDirectory As String = ConfigurationManager.AppSettings("AcctDataDirectory")
          Dim account As New Account()
          Dim accts As IEnumerable(Of Account) = account.GetAccounts(ID)
  
          For Each f As String In My.Computer.FileSystem.GetFiles(ParentDirectory)
              If f.EndsWith(".txt") Then
                  Dim LastSlashIndex As Integer = f.LastIndexOf("\")
                  Dim newFilePath As String = f.Insert(LastSlashIndex, "\Templates")
                  My.Computer.FileSystem.CopyFile(f, newFilePath)
              End If
          Next
  
          For Each acct As Account In accts
              If acct.ID &lt;&gt; ID Then
                  Dim ChildDirectory As String = ConfigurationManager.AppSettings("AcctDataDirectory") &amp; acct.ID
                  If My.Computer.FileSystem.DirectoryExists(ChildDirectory) = False Then
                      IO.Directory.CreateDirectory(ChildDirectory)
                  End If
                  My.Computer.FileSystem.DeleteDirectory(ChildDirectory, FileIO.DeleteDirectoryOption.DeleteAllContents)
                  My.Computer.FileSystem.CopyDirectory(ParentDirectory, ChildDirectory, True)
              Else
              End If
          Next
  End Sub
  </code></pre>