本文整理汇总了C#中Channel.TrySend方法的典型用法代码示例。如果您正苦于以下问题:C# Channel.TrySend方法的具体用法?C# Channel.TrySend怎么用?C# Channel.TrySend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Channel
的用法示例。
在下文中一共展示了Channel.TrySend方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: After
public static Channel<DateTime> After(TimeSpan after)
{
var ch = new Channel<DateTime>(1);
var t = new Timer(state => { ch.TrySend(DateTime.Now); ch.Close(); });
t.Change(after, TimeSpan.FromMilliseconds(-1));
return ch;
}
示例2: trySend_returns_true_when_spare_capacity
public void trySend_returns_true_when_spare_capacity()
{
var ch = new Channel<bool>(1);
Assert.IsTrue(ch.TrySend(true));
}
示例3: trySend_returns_false_when_capacity_reached
public void trySend_returns_false_when_capacity_reached()
{
var ch = new Channel<bool>(1);
ch.TrySend(true);
Assert.IsFalse(ch.TrySend(true));
}
示例4: trysend_on_a_closed_Channel_returns_false
public void trysend_on_a_closed_Channel_returns_false()
{
var ch = new Channel<int>(1);
ch.Close();
Assert.IsFalse(ch.TrySend(123));
}
示例5: trySend_returns_false_if_no_recievers
public void trySend_returns_false_if_no_recievers()
{
var ch = new Channel<bool>();
Assert.IsFalse(ch.TrySend(true));
}