本文整理汇总了C#中TimeoutHelper类的典型用法代码示例。如果您正苦于以下问题:C# TimeoutHelper类的具体用法?C# TimeoutHelper怎么用?C# TimeoutHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TimeoutHelper类属于命名空间,在下文中一共展示了TimeoutHelper类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: 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;
}
开发者ID:KKhurin,项目名称:wcf,代码行数:28,代码来源:HttpResponseMessageHelper.cs
示例2: OpenCollectionAsyncResult
public OpenCollectionAsyncResult(TimeSpan timeout, AsyncCallback otherCallback, object state, IList<ICommunicationObject> collection) : base(otherCallback, state)
{
this.timeoutHelper = new TimeoutHelper(timeout);
this.completedSynchronously = true;
this.count = collection.Count;
if (this.count == 0)
{
base.Complete(true);
}
else
{
for (int i = 0; i < collection.Count; i++)
{
if (this.exception != null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(this.exception);
}
CallbackState state2 = new CallbackState(this, collection[i]);
IAsyncResult result = collection[i].BeginOpen(this.timeoutHelper.RemainingTime(), nestedCallback, state2);
if (result.CompletedSynchronously)
{
collection[i].EndOpen(result);
this.Decrement(true);
}
}
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:27,代码来源:OpenCollectionAsyncResult.cs
示例3: CreateReceivingLinkAsync
public async Task<ReceivingAmqpLink> CreateReceivingLinkAsync(string path, IotHubConnectionString connectionString, TimeSpan timeout, uint prefetchCount)
{
this.OnCreateReceivingLink(connectionString);
var timeoutHelper = new TimeoutHelper(timeout);
AmqpSession session;
if (!this.FaultTolerantSession.TryGetOpenedObject(out session))
{
session = await this.FaultTolerantSession.GetOrCreateAsync(timeoutHelper.RemainingTime());
}
var linkAddress = this.BuildLinkAddress(connectionString, path);
var linkSettings = new AmqpLinkSettings()
{
Role = true,
TotalLinkCredit = prefetchCount,
AutoSendFlow = prefetchCount > 0,
Source = new Source() { Address = linkAddress.AbsoluteUri },
SndSettleMode = null, // SenderSettleMode.Unsettled (null as it is the default and to avoid bytes on the wire)
RcvSettleMode = (byte)ReceiverSettleMode.Second,
LinkName = Guid.NewGuid().ToString("N") // Use a human readable link name to help with debuggin
};
SetLinkSettingsCommonProperties(linkSettings, timeoutHelper.RemainingTime());
var link = new ReceivingAmqpLink(linkSettings);
link.AttachTo(session);
var audience = this.BuildAudience(connectionString, path);
await this.OpenLinkAsync(link, connectionString, audience, timeoutHelper.RemainingTime());
return link;
}
开发者ID:Fricsay,项目名称:azure-iot-sdks,代码行数:35,代码来源:IotHubConnection.cs
示例4: 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());
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:28,代码来源:ConnectionUpgradeHelper.cs
示例5: 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);
}
}
}
开发者ID:SoumikMukherjeeDOTNET,项目名称:wcf,代码行数:27,代码来源:OpenCollectionAsyncResult.cs
示例6: CreateSendingLinkAsync
public async Task<SendingAmqpLink> CreateSendingLinkAsync(string path, TimeSpan timeout)
{
var timeoutHelper = new TimeoutHelper(timeout);
AmqpSession session;
if (!this.faultTolerantSession.TryGetOpenedObject(out session))
{
session = await this.faultTolerantSession.GetOrCreateAsync(timeoutHelper.RemainingTime());
}
var linkAddress = this.connectionString.BuildLinkAddress(path);
var linkSettings = new AmqpLinkSettings()
{
Role = false,
InitialDeliveryCount = 0,
Target = new Target() { Address = linkAddress.AbsoluteUri },
SndSettleMode = null, // SenderSettleMode.Unsettled (null as it is the default and to avoid bytes on the wire)
RcvSettleMode = null, // (byte)ReceiverSettleMode.First (null as it is the default and to avoid bytes on the wire)
LinkName = Guid.NewGuid().ToString("N") // Use a human readable link name to help with debugging
};
SetLinkSettingsCommonProperties(linkSettings, timeoutHelper.RemainingTime());
var link = new SendingAmqpLink(linkSettings);
link.AttachTo(session);
await OpenLinkAsync(link, timeoutHelper.RemainingTime());
return link;
}
开发者ID:stefangordon,项目名称:azure-iot-sdks,代码行数:31,代码来源:IotHubConnection.cs
示例7: CreateSessionAsync
protected override async Task<AmqpSession> CreateSessionAsync(TimeSpan timeout)
{
var timeoutHelper = new TimeoutHelper(timeout);
if (this.iotHubTokenRefresher != null)
{
this.iotHubTokenRefresher.Cancel();
}
AmqpSession amqpSession = await base.CreateSessionAsync(timeoutHelper.RemainingTime());
#if !WINDOWS_UWP
if (this.AmqpTransportSettings.ClientCertificate == null)
{
#endif
this.iotHubTokenRefresher = new IotHubTokenRefresher(
amqpSession,
this.ConnectionString,
this.ConnectionString.AmqpEndpoint.AbsoluteUri
);
// Send Cbs token for new connection first
await this.iotHubTokenRefresher.SendCbsTokenAsync(timeoutHelper.RemainingTime());
#if !WINDOWS_UWP
}
#endif
return amqpSession;
}
开发者ID:Fricsay,项目名称:azure-iot-sdks,代码行数:29,代码来源:IotHubSingleTokenConnection.cs
示例8: FloodAsyncResult
public FloodAsyncResult(PeerNeighborManager owner, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state)
{
this.pending = new List<IAsyncResult>();
this.results = new Dictionary<IAsyncResult, IPeerNeighbor>();
this.thisLock = new object();
this.pnm = owner;
this.timeoutHelper = new TimeoutHelper(timeout);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:FloodAsyncResult.cs
示例9: BeginReceive
public AsyncReceiveResult BeginReceive(TimeSpan timeout, WaitCallback callback, object state)
{
if ((this.pendingMessage == null) && (this.pendingException == null))
{
this.readTimeoutHelper = new TimeoutHelper(timeout);
while (!this.isAtEOF)
{
AsyncReadResult result;
if (this.size > 0)
{
this.pendingMessage = this.DecodeMessage(this.readTimeoutHelper.RemainingTime());
if (this.pendingMessage != null)
{
this.PrepareMessage(this.pendingMessage);
return AsyncReceiveResult.Completed;
}
if (this.isAtEOF)
{
return AsyncReceiveResult.Completed;
}
}
if (this.size != 0)
{
throw Fx.AssertAndThrow("BeginReceive: DecodeMessage() should consume the outstanding buffer or return a message.");
}
if (!this.usingAsyncReadBuffer)
{
this.buffer = this.connection.AsyncReadBuffer;
this.usingAsyncReadBuffer = true;
}
this.pendingCallback = callback;
this.pendingCallbackState = state;
bool flag = true;
try
{
result = this.connection.BeginRead(0, this.buffer.Length, this.readTimeoutHelper.RemainingTime(), this.onAsyncReadComplete, null);
flag = false;
}
finally
{
if (flag)
{
this.pendingCallback = null;
this.pendingCallbackState = null;
}
}
if (result == AsyncReadResult.Queued)
{
return AsyncReceiveResult.Pending;
}
this.pendingCallback = null;
this.pendingCallbackState = null;
int bytesRead = this.connection.EndRead();
this.HandleReadComplete(bytesRead, false);
}
}
return AsyncReceiveResult.Completed;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:58,代码来源:SessionConnectionReader.cs
示例10: ChunkingWriter
internal ChunkingWriter(Message originalMessage,TimeoutHelper chunkingTimeout, IOutputChannel outputChannel) : base()
{
this.version = originalMessage.Version;
this.originalMessage = originalMessage;
this.chunkingTimeout = chunkingTimeout;
this.outputChannel = outputChannel;
this.startState = new StartChunkState();
chunkNum = 1;
}
开发者ID:spzenk,项目名称:sfdocsamples,代码行数:9,代码来源:ChunkingWriter.cs
示例11: Connect
public IConnection Connect(Uri uri, TimeSpan timeout)
{
if (DiagnosticUtility.ShouldTraceInformation)
{
TraceUtility.TraceEvent(TraceEventType.Information, 0x4002b, System.ServiceModel.SR.GetString("TraceCodeInitiatingTcpConnection"), new StringTraceRecord("Uri", uri.ToString()), this, null);
}
int port = uri.Port;
IPAddress[] iPAddresses = GetIPAddresses(uri);
Socket socket = null;
SocketException innerException = null;
if (port == -1)
{
port = 0x328;
}
int invalidAddressCount = 0;
TimeoutHelper helper = new TimeoutHelper(timeout);
for (int i = 0; i < iPAddresses.Length; i++)
{
if (helper.RemainingTime() == TimeSpan.Zero)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(CreateTimeoutException(uri, helper.OriginalTimeout, iPAddresses, invalidAddressCount, innerException));
}
AddressFamily addressFamily = iPAddresses[i].AddressFamily;
if ((addressFamily == AddressFamily.InterNetworkV6) && !Socket.OSSupportsIPv6)
{
iPAddresses[i] = null;
}
else
{
DateTime utcNow = DateTime.UtcNow;
try
{
socket = new Socket(addressFamily, SocketType.Stream, ProtocolType.Tcp);
socket.Connect(new IPEndPoint(iPAddresses[i], port));
innerException = null;
break;
}
catch (SocketException exception2)
{
invalidAddressCount++;
TraceConnectFailure(socket, exception2, uri, (TimeSpan) (DateTime.UtcNow - utcNow));
innerException = exception2;
socket.Close();
}
}
}
if (socket == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new EndpointNotFoundException(System.ServiceModel.SR.GetString("NoIPEndpointsFoundForHost", new object[] { uri.Host })));
}
if (innerException != null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(ConvertConnectException(innerException, uri, helper.ElapsedTime(), innerException));
}
return this.CreateConnection(socket);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:56,代码来源:SocketConnectionInitiator.cs
示例12: ChunkingReader
internal ChunkingReader(Message startMessage, int maxBufferedChunks, TimeoutHelper receiveTimeout)
{
//set innerReader
this.innerReader = startMessage.GetReaderAtBodyContents();
this.lockobject = new object();
this.messageId = ChunkingUtils.GetMessageHeader<Guid>(startMessage,
ChunkingUtils.MessageIdHeader, ChunkingUtils.ChunkNs);
this.bufferedChunks = new SynchronizedQueue<Message>(maxBufferedChunks);
this.receiveTimeout = receiveTimeout;
this.nextChunkNum = 1;
}
开发者ID:ssickles,项目名称:archive,代码行数:11,代码来源:ChunkingReader.cs
示例13: TimeoutStream
public TimeoutStream(Stream stream, TimeSpan timeout)
: base(stream)
{
if (!stream.CanTimeout)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("stream", SR.StreamDoesNotSupportTimeout);
}
_timeoutHelper = new TimeoutHelper(timeout);
ReadTimeout = TimeoutHelper.ToMilliseconds(timeout);
WriteTimeout = ReadTimeout;
}
开发者ID:SoumikMukherjeeDOTNET,项目名称:wcf,代码行数:12,代码来源:TimeoutStream.cs
示例14: Dispose
protected override void Dispose(bool disposing)
{
if (!_disposed)
{
if (disposing)
{
_timeoutHelper = default(TimeoutHelper);
}
_disposed = true;
}
base.Dispose(disposing);
}
开发者ID:AndyGerlicher,项目名称:wcf,代码行数:13,代码来源:TimeoutStream.cs
示例15: 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();
}
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:51,代码来源:ReceiveContext.cs
示例16: 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();
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:16,代码来源:SecurityListenerSettingsLifetimeManager.cs
示例17: Start
public void Start(TimeSpan timeout)
{
if (this.cancelled)
{
return;
}
this.timeoutHelper = new TimeoutHelper(timeout);
this.timeoutHelper.RemainingTime();
if (this.maxDelay == TimeSpan.Zero)
{
StartZeroDelay();
}
else
{
StartSchedule();
}
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:17,代码来源:RandomDelaySendsAsyncResult.cs
示例18: 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;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:18,代码来源:ConnectionUpgradeHelper.cs
示例19: CloseInitiate
void CloseInitiate(TimeSpan timeout)
{
TimeoutHelper timeoutHelper = new TimeoutHelper(timeout);
InstanceContext[] instances = this.ToArray();
for (int index = 0; index < instances.Length; index++)
{
InstanceContext instance = instances[index];
try
{
if (instance.State == CommunicationState.Opened)
{
IAsyncResult result = instance.BeginClose(timeoutHelper.RemainingTime(), Fx.ThunkCallback(new AsyncCallback(CloseInstanceContextCallback)), instance);
if (!result.CompletedSynchronously)
continue;
instance.EndClose(result);
}
else
{
instance.Abort();
}
}
catch (ObjectDisposedException e)
{
DiagnosticUtility.TraceHandledException(e, TraceEventType.Information);
}
catch (InvalidOperationException e)
{
DiagnosticUtility.TraceHandledException(e, TraceEventType.Information);
}
catch (CommunicationException e)
{
DiagnosticUtility.TraceHandledException(e, TraceEventType.Information);
}
catch (TimeoutException e)
{
if (TD.CloseTimeoutIsEnabled())
{
TD.CloseTimeout(e.Message);
}
DiagnosticUtility.TraceHandledException(e, TraceEventType.Information);
}
}
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:43,代码来源:InstanceContextManager.cs
示例20: ConnectAsync
public override bool ConnectAsync(TimeSpan timeout, TransportAsyncCallbackArgs callbackArgs)
{
this.callbackArgs = callbackArgs;
this.timeoutHelper = new TimeoutHelper(timeout);
TransportInitiator innerInitiator = this.transportSettings.InnerTransportSettings.CreateInitiator();
TransportAsyncCallbackArgs innerArgs = new TransportAsyncCallbackArgs();
innerArgs.CompletedCallback = OnInnerTransportConnected;
innerArgs.UserToken = this;
if (innerInitiator.ConnectAsync(timeout, innerArgs))
{
// pending
return true;
}
else
{
this.HandleInnerTransportConnected(innerArgs);
return !this.callbackArgs.CompletedSynchronously;
}
}
开发者ID:Azure,项目名称:azure-amqp,代码行数:20,代码来源:TlsTransportInitiator.cs
注:本文中的TimeoutHelper类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论