本文整理汇总了C#中Microsoft.WindowsAzure.Storage.Queue.CloudQueue.CreateIfNotExistsAsync方法的典型用法代码示例。如果您正苦于以下问题:C# CloudQueue.CreateIfNotExistsAsync方法的具体用法?C# CloudQueue.CreateIfNotExistsAsync怎么用?C# CloudQueue.CreateIfNotExistsAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.WindowsAzure.Storage.Queue.CloudQueue
的用法示例。
在下文中一共展示了CloudQueue.CreateIfNotExistsAsync方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
private async Task Initialize()
{
// Create the queues if they don't exist
_queue = _cloudQueueClient.GetQueueReference(UploadConfig.NotificationQueueName);
_poisonQueue = _cloudQueueClient.GetQueueReference(PoisionQueueName);
await Task.WhenAll(_queue.CreateIfNotExistsAsync(), _poisonQueue.CreateIfNotExistsAsync()).ConfigureAwait(false);
_initialized = true;
}
示例2: AzureQueueExt
public AzureQueueExt(string conectionString, string queueName, IQueueMessageSerializer serializer = null)
{
queueName = queueName.ToLower();
var storageAccount = CloudStorageAccount.Parse(conectionString);
var queueClient = storageAccount.CreateCloudQueueClient();
_queue = queueClient.GetQueueReference(queueName);
_queue.CreateIfNotExistsAsync().Wait();
_serializer = serializer ?? new DefaultQueueSerializer();
}
示例3: InitAsync
/// <summary>
/// Initialize the connection to Azure Storage.
/// If initReader is set to true, a timer will start that polls the queue every readerPollInterval, or by default 250ms.
/// </summary>
public async Task InitAsync(bool initReader = false, TimeSpan? readerPollInterval = null) {
CloudStorageAccount sta = CloudStorageAccount.Parse(connectionString);
var queueClient = sta.CreateCloudQueueClient();
queue = queueClient.GetQueueReference(queueName);
await queue.CreateIfNotExistsAsync();
if (initReader) {
await StartReaderAsync(readerPollInterval);
}
}
示例4: AzureQueueProvider
public AzureQueueProvider(string indexName)
{
var account = AzureConnectionHelper.CloudStorageAccount;
if (account != null)
{
var queueClient = account.CreateCloudQueueClient();
Queue = queueClient.GetQueueReference(indexName);
var t = Queue.CreateIfNotExistsAsync();
t.Wait();
}
}
示例5: AddMessageAndCreateIfNotExistsAsync
private static async Task AddMessageAndCreateIfNotExistsAsync(CloudQueue queue, CloudQueueMessage message, CancellationToken cancellationToken)
{
if (queue == null)
{
throw new ArgumentNullException("queue");
}
bool isQueueNotFoundException = false;
try
{
await queue.AddMessageAsync(message, cancellationToken);
return;
}
catch (StorageException exception)
{
if (!exception.IsNotFoundQueueNotFound())
{
throw;
}
isQueueNotFoundException = true;
}
Debug.Assert(isQueueNotFoundException);
await queue.CreateIfNotExistsAsync(cancellationToken);
await queue.AddMessageAsync(message, cancellationToken);
}