NOTE The code below is from asp.net.
If I have the (poorly written) code below
AmazonS3 s3Client = Amazon.AWSClientFactory.CreateAmazonS3Client();
// ...
// details elided
// ...
BackgroundWorker worker = new BackgroundWorker();
worker.DoWork += new DoWorkEventHandler((s, args) =>
{
s3Client.PutObject(titledRequest);
});
new Thread(() => worker.RunWorkerAsync()).Start();
Will the garbage collector be smart enough to never, ever collect the s3Client
object until the background worker is done with it?
Note, I'm kicking off the background worker inside of a thread only in order to fix an annoying error that gets raised within asp.net that happens when I fire off the background worker directly.