User guide

Table Of Contents
callback function uses the Amazon S3 client object to call the EndPutObject method to retrieve the
server response. The callback also extracts the start time for the operation and uses it to print the time
it took for the asynchronous operation to complete.
As in the previous examples, because exceptions that occur during the operation are received when En-
dPutObject is called, this call is placed within a try block.
asyncResult = client.BeginPutObject(
request, CallbackWithState, new ClientState { Client = client, Start = Date
Time.Now } );
Complete Sample
The following code sample demonstrates the various patterns that you can use when calling the asyn-
chronous request methods.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Threading;
using Amazon;
using Amazon.Runtime;
using Amazon.S3;
using Amazon.S3.Model;
namespace async_aws_net
{
class ClientState
{
AmazonS3Client client;
DateTime startTime;
public AmazonS3Client Client
{
get { return client; }
set { client = value; }
}
public DateTime Start
{
get { return startTime; }
set { startTime = value; }
}
}
class Program
{
public static void Main(string[] args)
{
TestPutObjectAsync();
}
public static void SimpleCallback(IAsyncResult asyncResult)
Version v2.0.0
21
AWS SDK for .NET Developer Guide
Asynchronous API for .NET 3.5