IAsyncResult InternalBeginAdd(Message message, bool isLast, TimeSpan timeout, object state, AsyncCallback callback, object asyncState) { MessageAttemptInfo attemptInfo = default(MessageAttemptInfo); bool isAddValid; lock (this.ThisLock) { if (isLast && this.last != 0) { throw Fx.AssertAndThrow("Can't add more than one last message."); } isAddValid = this.IsAddValid(); if (isAddValid) { ThrowIfRollover(); if (CanAdd()) { attemptInfo = AddToWindow(message, isLast, state); } else { AsyncQueueAdder adder = new AsyncQueueAdder(message, isLast, timeout, state, this, callback, asyncState); this.waitQueue.Enqueue(adder); return(adder); } } } return(new CompletedAsyncResult <bool, MessageAttemptInfo>(isAddValid, attemptInfo, callback, asyncState)); }
private IAsyncResult InternalBeginAdd(Message message, bool isLast, TimeSpan timeout, object state, AsyncCallback callback, object asyncState) { bool flag; MessageAttemptInfo parameter = new MessageAttemptInfo(); lock (this.ThisLock) { if (isLast && (this.last != 0L)) { throw Fx.AssertAndThrow("Can't add more than one last message."); } flag = this.IsAddValid(); if (flag) { this.ThrowIfRollover(); if (!this.CanAdd()) { AsyncQueueAdder item = new AsyncQueueAdder(message, isLast, timeout, state, this, callback, asyncState); this.waitQueue.Enqueue(item); return(item); } parameter = this.AddToWindow(message, isLast, state); } } return(new CompletedAsyncResult <bool, MessageAttemptInfo>(flag, parameter, callback, asyncState)); }
private bool InternalEndAdd(IAsyncResult result, out MessageAttemptInfo attemptInfo) { if (result is CompletedAsyncResult <bool, MessageAttemptInfo> ) { return(CompletedAsyncResult <bool, MessageAttemptInfo> .End(result, out attemptInfo)); } attemptInfo = AsyncQueueAdder.End((AsyncQueueAdder)result); return(true); }
private IAsyncResult InternalBeginAdd(Message message, bool isLast, TimeSpan timeout, object state, AsyncCallback callback, object asyncState) { bool flag; MessageAttemptInfo parameter = new MessageAttemptInfo(); lock (this.ThisLock) { if (isLast && (this.last != 0L)) { throw Fx.AssertAndThrow("Can't add more than one last message."); } flag = this.IsAddValid(); if (flag) { this.ThrowIfRollover(); if (!this.CanAdd()) { AsyncQueueAdder item = new AsyncQueueAdder(message, isLast, timeout, state, this, callback, asyncState); this.waitQueue.Enqueue(item); return item; } parameter = this.AddToWindow(message, isLast, state); } } return new CompletedAsyncResult<bool, MessageAttemptInfo>(flag, parameter, callback, asyncState); }
public static MessageAttemptInfo End(AsyncQueueAdder result) { AsyncResult.End<AsyncQueueAdder>(result); return result.attemptInfo; }
IAsyncResult InternalBeginAdd(Message message, bool isLast, TimeSpan timeout, object state, AsyncCallback callback, object asyncState) { MessageAttemptInfo attemptInfo = default(MessageAttemptInfo); bool isAddValid; lock (this.ThisLock) { if (isLast && this.last != 0) { throw Fx.AssertAndThrow("Can't add more than one last message."); } isAddValid = this.IsAddValid(); if (isAddValid) { ThrowIfRollover(); if (CanAdd()) { attemptInfo = AddToWindow(message, isLast, state); } else { AsyncQueueAdder adder = new AsyncQueueAdder(message, isLast, timeout, state, this, callback, asyncState); this.waitQueue.Enqueue(adder); return adder; } } } return new CompletedAsyncResult<bool, MessageAttemptInfo>(isAddValid, attemptInfo, callback, asyncState); }