本文整理汇总了C#中System.Runtime.TimeoutHelper.RemainingTime方法的典型用法代码示例。如果您正苦于以下问题:C# TimeoutHelper.RemainingTime方法的具体用法?C# TimeoutHelper.RemainingTime怎么用?C# TimeoutHelper.RemainingTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Runtime.TimeoutHelper
的用法示例。
在下文中一共展示了TimeoutHelper.RemainingTime方法的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: DecodeFramingFault
public static void DecodeFramingFault(ClientFramingDecoder decoder, IConnection connection, Uri via, string contentType, ref TimeoutHelper timeoutHelper)
{
ValidateReadingFaultString(decoder);
int offset = 0;
byte[] buffer = DiagnosticUtility.Utility.AllocateByteArray(0x100);
int size = connection.Read(buffer, offset, buffer.Length, timeoutHelper.RemainingTime());
while (size > 0)
{
int num3 = decoder.Decode(buffer, offset, size);
offset += num3;
size -= num3;
if (decoder.CurrentState == ClientFramingDecoderState.Fault)
{
ConnectionUtilities.CloseNoThrow(connection, timeoutHelper.RemainingTime());
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(FaultStringDecoder.GetFaultException(decoder.Fault, via.ToString(), contentType));
}
if (decoder.CurrentState != ClientFramingDecoderState.ReadingFaultString)
{
throw Fx.AssertAndThrow("invalid framing client state machine");
}
if (size == 0)
{
offset = 0;
size = connection.Read(buffer, offset, buffer.Length, timeoutHelper.RemainingTime());
}
}
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(decoder.CreatePrematureEOFException());
}
示例3: 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
示例4: 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
示例5: 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());
}
}
示例6: 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
示例7: 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
示例8: OnRequest
protected override Message OnRequest(Message request, TimeSpan timeout, bool last)
{
RequestContext context;
TimeoutHelper helper = new TimeoutHelper(timeout);
base.Binder.Send(request, helper.RemainingTime(), MaskingMode.None);
TimeSpan receiveTimeout = this.GetReceiveTimeout(helper.RemainingTime());
base.Binder.TryReceive(receiveTimeout, out context, MaskingMode.None);
if (context == null)
{
return null;
}
return context.RequestMessage;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:13,代码来源:SendReceiveReliableRequestor.cs
示例9: Abandon
public virtual void Abandon(Exception exception, TimeSpan timeout)
{
this.EnsureValidTimeout(timeout);
TimeoutHelper helper = new TimeoutHelper(timeout);
this.WaitForStateLock(helper.RemainingTime());
try
{
if (this.PreAbandon())
{
return;
}
}
finally
{
this.ReleaseStateLock();
}
bool flag = false;
try
{
if (exception == null)
{
this.OnAbandon(helper.RemainingTime());
}
else
{
if (TD.ReceiveContextAbandonWithExceptionIsEnabled())
{
TD.ReceiveContextAbandonWithException(base.GetType().ToString(), exception.GetType().ToString());
}
this.OnAbandon(exception, helper.RemainingTime());
}
lock (this.ThisLock)
{
this.ThrowIfFaulted();
this.ThrowIfNotAbandoning();
this.State = ReceiveContextState.Abandoned;
}
flag = true;
}
finally
{
if (!flag)
{
if (TD.ReceiveContextAbandonFailedIsEnabled())
{
TD.ReceiveContextAbandonFailed(base.GetType().ToString());
}
this.Fault();
}
}
}
示例10: BeginSecureOutgoingMessageAtInitiatorCore
protected override IAsyncResult BeginSecureOutgoingMessageAtInitiatorCore(Message message, string actor, TimeSpan timeout, AsyncCallback callback, object state)
{
SecurityToken token;
SecurityToken token2;
SecurityTokenParameters parameters;
IList<SupportingTokenSpecification> list;
this.GetTokensForOutgoingMessages(out token, out token2, out parameters);
TimeoutHelper helper = new TimeoutHelper(timeout);
if (!base.TryGetSupportingTokens(base.SecurityProtocolFactory, base.Target, base.Via, message, helper.RemainingTime(), false, out list))
{
return new SecureOutgoingMessageAsyncResult(actor, message, this, token, token2, parameters, helper.RemainingTime(), callback, state);
}
this.SetupDelayedSecurityExecution(actor, ref message, token, token2, parameters, list);
return new CompletedAsyncResult<Message>(message, callback, state);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:15,代码来源:InitiatorSessionSymmetricTransportSecurityProtocol.cs
示例11: Open
public void Open(TimeSpan timeout)
{
TimeoutHelper timeoutHelper = new TimeoutHelper(timeout);
if (this.securityProtocolFactory != null)
{
this.securityProtocolFactory.Open(false, timeoutHelper.RemainingTime());
}
if (this.sessionMode && this.sessionSettings != null)
{
this.sessionSettings.Open(timeoutHelper.RemainingTime());
}
this.innerListener.Open(timeoutHelper.RemainingTime());
this.SetBufferManager();
}
示例12: 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());
}
}
示例13: OpenCollectionAsyncResult
public OpenCollectionAsyncResult(TimeSpan timeout, AsyncCallback otherCallback, object state, IList<ICommunicationObject> collection)
: base(otherCallback, state)
{
_timeoutHelper = new TimeoutHelper(timeout);
_completedSynchronously = true;
_count = collection.Count;
if (_count == 0)
{
Complete(true);
return;
}
for (int index = 0; index < collection.Count; index++)
{
// Throw exception if there was a failure calling EndOpen in the callback (skips remaining items)
if (_exception != null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(_exception);
CallbackState callbackState = new CallbackState(this, collection[index]);
IAsyncResult result = collection[index].BeginOpen(_timeoutHelper.RemainingTime(), s_nestedCallback, callbackState);
if (result.CompletedSynchronously)
{
collection[index].EndOpen(result);
Decrement(true);
}
}
}
示例14: BeginSecureOutgoingMessageCore
protected override IAsyncResult BeginSecureOutgoingMessageCore(Message message, TimeSpan timeout, SecurityProtocolCorrelationState correlationState, AsyncCallback callback, object state)
{
SecurityToken token;
SecurityToken token2;
SecurityToken token3;
SecurityTokenParameters parameters;
IList<SupportingTokenSpecification> list;
this.GetTokensForOutgoingMessages(out token, out token2, out token3, out parameters);
TimeoutHelper helper = new TimeoutHelper(timeout);
if (base.TryGetSupportingTokens(this.Factory, base.Target, base.Via, message, helper.RemainingTime(), false, out list))
{
SecurityProtocolCorrelationState state2 = this.CreateCorrelationStateIfRequired();
this.SetUpDelayedSecurityExecution(ref message, token, token2, token3, parameters, list, state2);
return new CompletedAsyncResult<Message, SecurityProtocolCorrelationState>(message, state2, callback, state);
}
return new SecureOutgoingMessageAsyncResult(message, this, token, token2, token3, parameters, helper.RemainingTime(), callback, state);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:17,代码来源:InitiatorSessionSymmetricMessageSecurityProtocol.cs
示例15: InitiateUpgrade
public static bool InitiateUpgrade(StreamUpgradeInitiator upgradeInitiator, ref IConnection connection, ClientFramingDecoder decoder, IDefaultCommunicationTimeouts defaultTimeouts, ref TimeoutHelper timeoutHelper)
{
for (string str = upgradeInitiator.GetNextUpgrade(); str != null; str = upgradeInitiator.GetNextUpgrade())
{
EncodedUpgrade upgrade = new EncodedUpgrade(str);
connection.Write(upgrade.EncodedBytes, 0, upgrade.EncodedBytes.Length, true, timeoutHelper.RemainingTime());
byte[] buffer = new byte[1];
int count = connection.Read(buffer, 0, buffer.Length, timeoutHelper.RemainingTime());
if (!ValidateUpgradeResponse(buffer, count, decoder))
{
return false;
}
ConnectionStream stream = new ConnectionStream(connection, defaultTimeouts);
Stream stream2 = upgradeInitiator.InitiateUpgrade(stream);
connection = new StreamConnection(stream2, stream);
}
return true;
}