本文整理汇总了C#中IClientChannel.Close方法的典型用法代码示例。如果您正苦于以下问题:C# IClientChannel.Close方法的具体用法?C# IClientChannel.Close怎么用?C# IClientChannel.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IClientChannel
的用法示例。
在下文中一共展示了IClientChannel.Close方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CloseClientChannel
public static void CloseClientChannel(IClientChannel c)
{
try {
c.Close();
} catch {
c.Abort();
} finally {
c.Dispose();
}
}
示例2: CloseChannel
private static void CloseChannel(IClientChannel channel)
{
try
{
channel.Close();
}
catch (TimeoutException)
{
channel.Abort();
}
catch (CommunicationException)
{
channel.Abort();
}
catch (Exception)
{
channel.Abort();
throw;
}
}
示例3: AfterSendAsync
/// <summary>
/// After sending, we check if the write was successful or if it was a fire-and-forget.
/// </summary>
/// <param name="sendTask">The task of the send operation.</param>
/// <param name="tcsResponse"></param>
/// <param name="isFireAndForget">True, if we don't expect a response message.</param>
/// <param name="channel"></param>
private async Task AfterSendAsync(Task sendTask, TaskCompletionSource<Message.Message> tcsResponse, bool isFireAndForget, IClientChannel channel)
{
// TODO use for UDP connections, too
await sendTask;
if (sendTask.IsFaulted)
{
string msg = String.Format("Failed to write channel the request {0} {1}.", tcsResponse.Task.AsyncState,
sendTask.Exception);
Logger.Warn(msg);
tcsResponse.SetException(sendTask.TryGetException());
}
if (isFireAndForget)
{
Logger.Debug("Fire and forget message {0} sent. Close channel {1} now. {0}", tcsResponse.Task.AsyncState, channel);
tcsResponse.SetResult(null); // set FF result
// close channel now
}
else
{
//.NET specific, we wait here for the response
// receive response message
// processes client-side inbound pipeline
await channel.ReceiveMessageAsync();
}
channel.Close(); // TODO not needed, receive method closes...
}