User guide

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 IAsyncResult
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