User guide
Table Of Contents
- AWS SDK for .NET
- Table of Contents
- AWS SDK for .NET Developer Guide
- Getting Started with the AWS SDK for .NET
- Programming with the AWS SDK for .NET
- AWS SDK for .NET Tutorials and Examples
- Managing ASP.NET Session State with Amazon DynamoDB
- Tutorial: Creating Amazon EC2 Instances with the AWS SDK for .NET
- Tutorial: Grant Access Using an IAM Role and the AWS SDK for .NET
- Tutorial: Amazon EC2 Spot Instances
- Creating and Using an Amazon SQS Queue with the AWS SDK for .NET
- Creating an Amazon Route 53 Hosted Zone and Adding Resource Record Sets
- Additional Resources
- Document History

void Callback(IAsyncResult asyncResult)
Object state
The third parameter, state, is a user-defined object that is made available to the callback function as
the AsyncState property of the asyncResult parameter, that is, asyncResult.AsyncState.
Calling Patterns
• Passing a callback function and a state object.
• Passing a callback function, but passing null for the state object.
• Passing null for both the callback function and the state object.
This topic provides an example of each of these patterns.
Using IAsyncResult.AsyncWaitHandle
In some circumstances, the code that calls the Begin method might need to enable another method that
it calls to wait on the completion of the asynchronous operation. In these situations, it can pass the
method the WaitHandle returned by the IAsyncResult.AsyncWaitHandle property of the IAsyn-
cResult return value.The method can then wait for the asynchronous operation to complete by calling
WaitOne on this WaitHandle.
Examples
All of the following examples assume the following initialization code.
public static void TestPutObjectAsync()
{
// Create a client
AmazonS3Client client = new AmazonS3Client();
PutObjectResponse response;
IAsyncResult asyncResult;
//
// Create a PutObject request
//
// You will need to use your own bucket name below in order
// to run this sample code.
//
PutObjectRequest request = new PutObjectRequest
{
BucketName = "PUT YOUR OWN EXISTING BUCKET NAME HERE",
Key = "Item",
ContentBody = "This is sample content..."
};
//
// additional example code
//
}
Version v2.0.0
18
AWS SDK for .NET Developer Guide
Asynchronous API for .NET 3.5