-
Notifications
You must be signed in to change notification settings - Fork 97
Expand file tree
/
Copy pathQueueingServiceExamples.cs
More file actions
138 lines (125 loc) · 5.93 KB
/
Copy pathQueueingServiceExamples.cs
File metadata and controls
138 lines (125 loc) · 5.93 KB
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
namespace CSharpCodeSamples
{
using System;
using System.Collections.ObjectModel;
using System.Threading;
using System.Threading.Tasks;
using net.openstack.Core;
using net.openstack.Core.Collections;
using net.openstack.Core.Domain;
using net.openstack.Core.Domain.Queues;
using net.openstack.Core.Providers;
using net.openstack.Providers.Rackspace;
public class QueueingServiceExamples
{
CloudIdentity identity =
new CloudIdentity()
{
Username = "MyUser",
APIKey = "API_KEY_HERE"
};
// use the default region for the account
string region = null;
// create a new client ID for this instance
Guid clientId = Guid.NewGuid();
// access Cloud Queues over the public Internet
bool internalUrl = false;
// use a default CloudIdentityProvider for authentication
IIdentityProvider identityProvider = null;
public async Task GetHomeAsyncAwait()
{
#region GetHomeAsync (await)
IQueueingService queueingService = new CloudQueuesProvider(identity, region, clientId, internalUrl, identityProvider);
HomeDocument createdQueue = await queueingService.GetHomeAsync(CancellationToken.None);
#endregion
}
public void GetHome()
{
#region GetHomeAsync (TPL)
IQueueingService queueingService = new CloudQueuesProvider(identity, region, clientId, internalUrl, identityProvider);
Task<HomeDocument> task = queueingService.GetHomeAsync(CancellationToken.None);
#endregion
}
public async Task GetNodeHealthAsyncAwait()
{
#region GetNodeHealthAsync (await)
IQueueingService queueingService = new CloudQueuesProvider(identity, region, clientId, internalUrl, identityProvider);
await queueingService.GetNodeHealthAsync(CancellationToken.None);
#endregion
}
public void GetNodeHealth()
{
#region GetNodeHealthAsync (TPL)
IQueueingService queueingService = new CloudQueuesProvider(identity, region, clientId, internalUrl, identityProvider);
Task task = queueingService.GetNodeHealthAsync(CancellationToken.None);
#endregion
}
public async Task CreateQueueAsyncAwait()
{
#region CreateQueueAsync (await)
IQueueingService queueingService = new CloudQueuesProvider(identity, region, clientId, internalUrl, identityProvider);
QueueName queueName = new QueueName("ExampleQueue");
bool createdQueue = await queueingService.CreateQueueAsync(queueName, CancellationToken.None);
#endregion
}
public void CreateQueue()
{
#region CreateQueueAsync (TPL)
IQueueingService queueingService = new CloudQueuesProvider(identity, region, clientId, internalUrl, identityProvider);
QueueName queueName = new QueueName("ExampleQueue");
Task<bool> task = queueingService.CreateQueueAsync(queueName, CancellationToken.None);
#endregion
}
public async Task DeleteQueueAsyncAwait()
{
#region DeleteQueueAsync (await)
IQueueingService queueingService = new CloudQueuesProvider(identity, region, clientId, internalUrl, identityProvider);
QueueName queueName = new QueueName("ExampleQueue");
await queueingService.DeleteQueueAsync(queueName, CancellationToken.None);
#endregion
}
public void DeleteQueue()
{
#region DeleteQueueAsync (TPL)
IQueueingService queueingService = new CloudQueuesProvider(identity, region, clientId, internalUrl, identityProvider);
QueueName queueName = new QueueName("ExampleQueue");
Task task = queueingService.DeleteQueueAsync(queueName, CancellationToken.None);
#endregion
}
public async Task ListQueuesAsyncAwait()
{
#region ListQueuesAsync (await)
IQueueingService queueingService = new CloudQueuesProvider(identity, region, clientId, internalUrl, identityProvider);
ReadOnlyCollectionPage<CloudQueue> queuesPage = await queueingService.ListQueuesAsync(null, null, true, CancellationToken.None);
ReadOnlyCollection<CloudQueue> queues = await queuesPage.GetAllPagesAsync(CancellationToken.None, null);
#endregion
}
public void ListQueues()
{
#region ListQueuesAsync (TPL)
IQueueingService queueingService = new CloudQueuesProvider(identity, region, clientId, internalUrl, identityProvider);
Task<ReadOnlyCollectionPage<CloudQueue>> queuesPageTask = queueingService.ListQueuesAsync(null, null, true, CancellationToken.None);
Task<ReadOnlyCollection<CloudQueue>> queuesTask =
queuesPageTask
.ContinueWith(task => task.Result.GetAllPagesAsync(CancellationToken.None, null))
.Unwrap();
#endregion
}
public async Task QueueExistsAsyncAwait()
{
#region QueueExistsAsync (await)
IQueueingService queueingService = new CloudQueuesProvider(identity, region, clientId, internalUrl, identityProvider);
QueueName queueName = new QueueName("ExampleQueue");
bool exists = await queueingService.QueueExistsAsync(queueName, CancellationToken.None);
#endregion
}
public void QueueExists()
{
#region QueueExistsAsync (TPL)
IQueueingService queueingService = new CloudQueuesProvider(identity, region, clientId, internalUrl, identityProvider);
QueueName queueName = new QueueName("ExampleQueue");
Task<bool> task = queueingService.QueueExistsAsync(queueName, CancellationToken.None);
#endregion
}
}
}