本文整理汇总了C#中System.Runtime.TimeoutHelper类的典型用法代码示例。如果您正苦于以下问题:C# TimeoutHelper类的具体用法?C# TimeoutHelper怎么用?C# TimeoutHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TimeoutHelper类属于System.Runtime命名空间,在下文中一共展示了TimeoutHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BeginWrite
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int size, bool immediate, TimeSpan timeout, AsyncCallback callback, object state)
{
ThreadTrace.Trace("BC:BeginWrite");
TimeoutHelper helper = new TimeoutHelper(timeout);
this.Flush(helper.RemainingTime());
return base.BeginWrite(buffer, offset, size, immediate, helper.RemainingTime(), callback, state);
}
示例2: OnOpen
public override void OnOpen(TimeSpan timeout)
{
TimeoutHelper timeoutHelper = new TimeoutHelper(timeout);
base.OnOpen(timeoutHelper.RemainingTime());
if (this.Factory.ActAsInitiator)
{
// 1. Create a token requirement for the provider
InitiatorServiceModelSecurityTokenRequirement tokenProviderRequirement = CreateInitiatorTokenRequirement();
// 2. Create a provider
SecurityTokenProvider tokenProvider = this.Factory.SecurityTokenManager.CreateSecurityTokenProvider(tokenProviderRequirement);
SecurityUtils.OpenTokenProviderIfRequired(tokenProvider, timeoutHelper.RemainingTime());
if (this.Factory.SecurityTokenParameters.HasAsymmetricKey)
{
this.initiatorAsymmetricTokenProvider = tokenProvider;
}
else
{
this.initiatorSymmetricTokenProvider = tokenProvider;
}
// 3. Create a token requirement for authenticator
InitiatorServiceModelSecurityTokenRequirement tokenAuthenticatorRequirement = CreateInitiatorTokenRequirement();
// 4. Create authenticator (we dont support out of band resolvers on the client side
SecurityTokenResolver outOfBandTokenResolver;
this.initiatorTokenAuthenticator = this.Factory.SecurityTokenManager.CreateSecurityTokenAuthenticator(tokenAuthenticatorRequirement, out outOfBandTokenResolver);
SecurityUtils.OpenTokenAuthenticatorIfRequired(this.initiatorTokenAuthenticator, timeoutHelper.RemainingTime());
}
}
示例3: ParseIncomingResponse
internal async Task<Message> ParseIncomingResponse(TimeoutHelper timeoutHelper)
{
ValidateAuthentication();
ValidateResponseStatusCode();
bool hasContent = await ValidateContentTypeAsync();
Message message = null;
if (!hasContent)
{
if (_encoder.MessageVersion == MessageVersion.None)
{
message = new NullMessage();
}
else
{
return null;
}
}
else
{
message = await ReadStreamAsMessageAsync(timeoutHelper);
}
var exception = ProcessHttpAddressing(message);
Contract.Assert(exception == null, "ProcessHttpAddressing should not set an exception after parsing a response message.");
return message;
}
示例4: Reply
public override void Reply(Message message, TimeSpan timeout)
{
TimeoutHelper helper = new TimeoutHelper(timeout);
Message message2 = message;
if (message != null)
{
CorrelationCallbackMessageProperty property;
this.contextProtocol.OnOutgoingMessage(message, this);
if (CorrelationCallbackMessageProperty.TryGet(message, out property))
{
ContextExchangeCorrelationHelper.AddOutgoingCorrelationCallbackData(property, message, false);
if (property.IsFullyDefined)
{
message2 = property.FinalizeCorrelation(message, helper.RemainingTime());
message2.Properties.Remove(CorrelationCallbackMessageProperty.Name);
}
}
}
try
{
this.innerContext.Reply(message2, helper.RemainingTime());
}
finally
{
if ((message != null) && !object.ReferenceEquals(message, message2))
{
message2.Close();
}
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:30,代码来源:ContextChannelRequestContext.cs
示例5: OnCreateSecurityProtocol
protected override SecurityProtocol OnCreateSecurityProtocol(EndpointAddress target, Uri via, object listenerSecurityState, TimeSpan timeout)
{
SecurityProtocolFactory protocolFactoryForOutgoingMessages = this.ProtocolFactoryForOutgoingMessages;
SecurityProtocolFactory protocolFactoryForIncomingMessages = this.ProtocolFactoryForIncomingMessages;
TimeoutHelper helper = new TimeoutHelper(timeout);
SecurityProtocol outgoingProtocol = (protocolFactoryForOutgoingMessages == null) ? null : protocolFactoryForOutgoingMessages.CreateSecurityProtocol(target, via, listenerSecurityState, false, helper.RemainingTime());
return new DuplexSecurityProtocol(outgoingProtocol, (protocolFactoryForIncomingMessages == null) ? null : protocolFactoryForIncomingMessages.CreateSecurityProtocol(null, null, listenerSecurityState, false, helper.RemainingTime()));
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:DuplexSecurityProtocolFactory.cs
示例6: LoadRetryAsyncResult
public LoadRetryAsyncResult(SqlWorkflowInstanceStore store, System.Runtime.DurableInstancing.InstancePersistenceContext context, System.Runtime.DurableInstancing.InstancePersistenceCommand command, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state)
{
this.InstanceStore = store;
this.InstancePersistenceContext = context;
this.InstancePersistenceCommand = command;
this.commandTimeout = new TimeoutHelper(timeout);
this.InstanceStore.BeginTryCommandInternal(this.InstancePersistenceContext, this.InstancePersistenceCommand, this.commandTimeout.RemainingTime(), onTryCommandCallback, this);
}
示例7: TimeoutStream
public TimeoutStream(Stream stream, ref TimeoutHelper timeoutHelper) : base(stream)
{
if (!stream.CanTimeout)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("stream", System.ServiceModel.SR.GetString("StreamDoesNotSupportTimeout"));
}
this.timeoutHelper = timeoutHelper;
}
示例8: OnClose
protected override void OnClose(TimeSpan timeout)
{
TimeoutHelper timeoutHelper = new TimeoutHelper(timeout);
base.OnClose(timeoutHelper.RemainingTime());
if (this.transportManagerContainer != null && !TransferTransportManagers())
{
this.transportManagerContainer.Close(timeoutHelper.RemainingTime());
}
}
示例9: SendReceiveAsyncResult
internal SendReceiveAsyncResult(SendReceiveReliableRequestor requestor, Message request, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state)
{
this.requestor = requestor;
this.request = request;
this.timeoutHelper = new TimeoutHelper(timeout);
if (this.BeginSend())
{
base.Complete(true);
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:10,代码来源:SendReceiveReliableRequestor.cs
示例10: OnClose
protected override void OnClose(TimeSpan timeout)
{
TimeoutHelper helper = new TimeoutHelper(timeout);
base.Connection.Write(SingletonEncoder.EndBytes, 0, SingletonEncoder.EndBytes.Length, true, helper.RemainingTime());
this.connectionDemuxer.ReuseConnection(this.rawConnection, helper.RemainingTime());
if (this.channelBindingToken != null)
{
this.channelBindingToken.Dispose();
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:10,代码来源:ServerSingletonConnectionReader.cs
示例11: SqlCommandAsyncResult
public SqlCommandAsyncResult(SqlCommand sqlCommand, string connectionString, DependentTransaction dependentTransaction, TimeSpan timeout, int retryCount, int maximumRetries, AsyncCallback callback, object state) : base(callback, state)
{
long num = Math.Min(timeout.Ticks, MaximumOpenTimeout.Ticks);
this.sqlCommand = sqlCommand;
this.connectionString = connectionString;
this.dependentTransaction = dependentTransaction;
this.timeoutHelper = new TimeoutHelper(TimeSpan.FromTicks(num));
this.retryCount = retryCount;
this.maximumRetries = maximumRetries;
}
示例12: Abandon
public virtual void Abandon(Exception exception, TimeSpan timeout)
{
EnsureValidTimeout(timeout);
TimeoutHelper timeoutHelper = new TimeoutHelper(timeout);
this.WaitForStateLock(timeoutHelper.RemainingTime());
try
{
if (PreAbandon())
{
return;
}
}
finally
{
// Abandon can never be reverted, release the state lock.
this.ReleaseStateLock();
}
bool success = false;
try
{
if (exception == null)
{
OnAbandon(timeoutHelper.RemainingTime());
}
else
{
if (TD.ReceiveContextAbandonWithExceptionIsEnabled())
{
TD.ReceiveContextAbandonWithException(this.eventTraceActivity, this.GetType().ToString(), exception.GetType().ToString());
}
OnAbandon(exception, timeoutHelper.RemainingTime());
}
lock (ThisLock)
{
ThrowIfFaulted();
ThrowIfNotAbandoning();
this.State = ReceiveContextState.Abandoned;
}
success = true;
}
finally
{
if (!success)
{
if (TD.ReceiveContextAbandonFailedIsEnabled())
{
TD.ReceiveContextAbandonFailed(this.eventTraceActivity, this.GetType().ToString());
}
Fault();
}
}
}
示例13: BeginSecureOutgoingMessageAtInitiatorCore
protected virtual IAsyncResult BeginSecureOutgoingMessageAtInitiatorCore(Message message, string actor, TimeSpan timeout, AsyncCallback callback, object state)
{
IList<SupportingTokenSpecification> list;
TimeoutHelper helper = new TimeoutHelper(timeout);
if (base.TryGetSupportingTokens(base.SecurityProtocolFactory, base.Target, base.Via, message, helper.RemainingTime(), false, out list))
{
this.SetUpDelayedSecurityExecution(ref message, actor, list);
return new CompletedAsyncResult<Message>(message, callback, state);
}
return new SecureOutgoingMessageAsyncResult(actor, message, this, timeout, callback, state);
}
示例14: CloseCommunicationAsyncResult
public CloseCommunicationAsyncResult(TimeSpan timeout, AsyncCallback callback, object state, object mutex) : base(callback, state)
{
this.timeout = timeout;
this.timeoutHelper = new TimeoutHelper(timeout);
this.mutex = mutex;
if (timeout < TimeSpan.Zero)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new TimeoutException(System.ServiceModel.SR.GetString("SFxCloseTimedOut1", new object[] { timeout })));
}
this.timer = new IOThreadTimer(new Action<object>(CloseCommunicationAsyncResult.TimeoutCallback), this, true);
this.timer.Set(timeout);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:12,代码来源:CloseCommunicationAsyncResult.cs
示例15: OnClose
public override void OnClose(TimeSpan timeout)
{
TimeoutHelper helper = new TimeoutHelper(timeout);
if (this.forwardProtocolFactory != null)
{
this.forwardProtocolFactory.Close(false, helper.RemainingTime());
}
if (this.reverseProtocolFactory != null)
{
this.reverseProtocolFactory.Close(false, helper.RemainingTime());
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:12,代码来源:DuplexSecurityProtocolFactory.cs