User guide
PutItemResponse PutItem(
PutItemRequest putItemRequest
)
Asynchronous Method
IAsyncResult BeginPutItem(
GetSessionTokenRequest getSessionTokenRequest,
AsyncCallback callback,
Object state
)
AsyncCallback callback
The callback function is called when the asynchronous operation completes.When the function is called,
it receives a single parameter of type IAsyncResult. The callback function has the following signature.
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
Version v2.0.0
27
AWS SDK for .NET Developer Guide
Asynchronous API for .NET 3.5