#include "Stdafx.h" using namespace net::openstack::Core; using namespace net::openstack::Core::Collections; using namespace net::openstack::Core::Domain; using namespace net::openstack::Core::Providers; using namespace net::openstack::Core::Domain::Queues; using namespace net::openstack::Providers::Rackspace; using namespace System; using namespace System::Collections::ObjectModel; using namespace System::Threading; using namespace System::Threading::Tasks; ref class QueueingServiceExamples { private: static CloudIdentity^ identity = gcnew CloudIdentity(); static String^ region = nullptr; static Guid clientId = Guid::NewGuid(); static bool internalUrl = false; static IIdentityProvider^ identityProvider = nullptr; public: void GetHome() { #pragma region GetHomeAsync (TPL) IQueueingService^ queueingService = gcnew CloudQueuesProvider(identity, region, clientId, internalUrl, identityProvider); Task^ task = queueingService->GetHomeAsync(CancellationToken::None); #pragma endregion } void GetNodeHealth() { #pragma region GetNodeHealthAsync (TPL) IQueueingService^ queueingService = gcnew CloudQueuesProvider(identity, region, clientId, internalUrl, identityProvider); Task^ task = queueingService->GetNodeHealthAsync(CancellationToken::None); #pragma endregion } void CreateQueue() { #pragma region CreateQueueAsync (TPL) IQueueingService^ queueingService = gcnew CloudQueuesProvider(identity, region, clientId, internalUrl, identityProvider); QueueName^ queueName = gcnew QueueName("ExampleQueue"); Task^ task = queueingService->CreateQueueAsync(queueName, CancellationToken::None); #pragma endregion } void DeleteQueue() { #pragma region DeleteQueueAsync (TPL) IQueueingService^ queueingService = gcnew CloudQueuesProvider(identity, region, clientId, internalUrl, identityProvider); QueueName^ queueName = gcnew QueueName("ExampleQueue"); Task^ task = queueingService->DeleteQueueAsync(queueName, CancellationToken::None); #pragma endregion } #pragma region ListQueuesAsync (TPL) void ListQueues() { IQueueingService^ queueingService = gcnew CloudQueuesProvider(identity, region, clientId, internalUrl, identityProvider); Task^>^ queuesPageTask = queueingService->ListQueuesAsync(nullptr, Nullable(), true, CancellationToken::None); auto func = gcnew Func^>^, Task^>^>(GetAllPagesContinuationAsync); Task^>^ queuesTask = TaskExtensions::Unwrap(queuesPageTask->ContinueWith(func)); } generic static Task^>^ GetAllPagesContinuationAsync(Task^>^ pageTask) { return ReadOnlyCollectionPageExtensions::GetAllPagesAsync(pageTask->Result, CancellationToken::None, static_cast^>^>(nullptr)); } #pragma endregion void QueueExists() { #pragma region QueueExistsAsync (TPL) IQueueingService^ queueingService = gcnew CloudQueuesProvider(identity, region, clientId, internalUrl, identityProvider); QueueName^ queueName = gcnew QueueName("ExampleQueue"); Task^ task = queueingService->QueueExistsAsync(queueName, CancellationToken::None); #pragma endregion } };