title: Using ThreadPool.QueueUserWorkItem - thread unexpectedly exits
body: <p>I have the following method:</p>
  
  <pre><code>    public void PutFile(string ID, Stream content)
      {
          try
          {
              ThreadPool.QueueUserWorkItem(o =&gt; putFileWorker(ID, content));
          }
  
          catch (Exception ex)
          {
              OnPutFileError(this, new ExceptionEventArgs { Exception = ex });
          }
      }
  </code></pre>
  
  <p>The putFileWorker method looks like this:</p>
  
  <pre><code>    private void putFileWorker(string ID, Stream content)
      {
          //Get bucket name:
          var bucketName = getBucketName(ID)
              .ToLower();
  
          //get file key
          var fileKey = getFileKey(ID);
  
          try
          {
              //if the bucket doesn't exist, create it
              if (!Amazon.S3.Util.AmazonS3Util.DoesS3BucketExist(bucketName, s3client))
                  s3client.PutBucket(new PutBucketRequest { BucketName = bucketName, BucketRegion = S3Region.EU });
  
              PutObjectRequest request = new PutObjectRequest();
              request.WithBucketName(bucketName)
                  .WithKey(fileKey)
                  .WithInputStream(content);
  
              S3Response response = s3client.PutObject(request);
              var xx = response.Headers;
  
              OnPutFileCompleted(this, new ValueEventArgs { Value = ID });
          }
  
          catch (Exception e)
          {
              OnPutFileError(this, new ExceptionEventArgs { Exception = e });
          }
      }
  </code></pre>
  
  <p>I've created a little console app to test this.
  I wire up event handlers for the OnPutFileError and OnPutFileCompleted events.</p>
  
  <p>If I call my PutFile method, and step into this, it gets to the "//if the bucket doesn't exist, create it" line, then exits. No exception, no errors, nothing.
  It doesn't complete (i've set breakpoints on my event handlers too) - it just exits.</p>
  
  <p>If I run the same method without the <strong>ThreadPool.QueueUserWorkItem</strong> then it runs fine...</p>
  
  <p>Am I missing something?</p>