Amazon AWS SDK Guida Utente Pagina 25

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 71
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 24
called. The 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
EndPutObject 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
asynchronous 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
Vedere la pagina 24
1 2 ... 20 21 22 23 24 25 26 27 28 29 30 ... 70 71

Commenti su questo manuale

Nessun commento