Amazon AWS SDK Guida Utente Pagina 32: Simple Callback
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
//
// 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
//
}
No Callback Specified
The following example code calls
BeginPutObject
, performs some work, then calls
EndPutObject
to
retrieve the service response.The call to
EndPutObject
is enclosed in a
try
block to catch any exceptions
that might have been thrown during the operation.
asyncResult = client.BeginPutObject(request, null, null);
while ( ! asyncResult.IsCompleted ) {
//
// Do some work here
//
}
try {
response = client.EndPutObject(asyncResult);
}
catch (AmazonS3Exception s3Exception) {
//
// Code to process exception
//
}
Simple Callback
This example assumes that the following callback function has been defined.
public static void SimpleCallback(IAsyncResult asyncResult)
{
Console.WriteLine("Finished PutObject operation with simple callback");
}
The following line of code calls
BeginPutObject
and specifies the above callback function. When the
PutObject
operation completes, the callback function is called. The call to
BeginPutObject
specifies
null
for the
state
parameter because the simple callback function does not access the
AsyncState
property of the
asyncResult
parameter. Neither the calling code or the callback function call
EndPutObject
. Therefore, the service response is effectively discarded and any exceptions that occur
during the operation are ignored.
asyncResult = client.BeginPutObject(request, SimpleCallback, null);
Version v2.0.0
28
AWS SDK for .NET Developer Guide
Asynchronous API for .NET 3.5
File PDF · ·
Domande su Amazon AWS SDK
Non ci sono ancora domande su questo manuale. Fate la prima.
Prodotti e manuali riguardanti Software Amazon AWS SDK
- Software Amazon Redshift Manuale Utente
(24 pagine) - Software Amazon Redshift Manuale Utente
(11 pagine) - Software Amazon AWS SDK Guida Utente
(73 pagine)