/// <summary> /// Creates and initializes a retryable write operation context. /// </summary> /// <param name="binding">The binding.</param> /// <param name="retryRequested">if set to <c>true</c> [retry requested].</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>A retryable write context.</returns> public static async Task <RetryableWriteContext> CreateAsync(IWriteBinding binding, bool retryRequested, CancellationToken cancellationToken) { var context = new RetryableWriteContext(binding, retryRequested); try { await context.InitializeAsync(cancellationToken).ConfigureAwait(false); ChannelPinningHelper.PinChannellIfRequired( context.ChannelSource, context.Channel, context.Binding.Session); return(context); } catch { context.Dispose(); throw; } }
// public static methods /// <summary> /// Creates and initializes a retryable write operation context. /// </summary> /// <param name="binding">The binding.</param> /// <param name="retryRequested">if set to <c>true</c> [retry requested].</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>A retryable write context.</returns> public static RetryableWriteContext Create(IWriteBinding binding, bool retryRequested, CancellationToken cancellationToken) { var context = new RetryableWriteContext(binding, retryRequested); try { context.Initialize(cancellationToken); ChannelPinningHelper.PinChannellIfRequired( context.ChannelSource, context.Channel, context.Binding.Session); return(context); } catch { context.Dispose(); throw; } }