title: WCF service running a background thread to speed up execution time
body: <p>I have a per-call WCF service that serves a number of clients. I'm looking to speed up the services by running some background processes so they don't block or slow down the main function of the services.</p>
  
  <p>One example is that the main function needs to return a set of data, while the background thread needs to record some statistics based on the parameter(s).</p>
  
  <p>Code:</p>
  
  <pre><code>Public Function GetAccountDetails(id As Integer) As AccountDetails
  
      Dim retVal As New AccountDetails
      Dim a As New Accounts
      retVal = a.GetAccountDetails(id)
  
      Dim t As New Thread(New ThreadStart(Sub()
                                               Dim s As New Statistic
                                               s.StatisticType = StatisticType.GetAccount
                                               s.Parameter = id.ToString
                                               s.Record()
                                          End Sub))
      t.Start()
  
      Return retVal
  
  End Function
  </code></pre>
  
  <p>If I use this background thread to record the statistic it doesn't block the main thread from returning the data to the client.</p>
  
  <p>It's been working well in test scenarios, but my question is, are there any dangers with leaving this thread to execute without Joining it before returning the data to the client?
  Could there potentially be any loss of statistic data?
  Could there be potential memory problems on the server side?</p>
  
  <p>Thanks.</p>