本文整理汇总了C#中Port.GetReceivers方法的典型用法代码示例。如果您正苦于以下问题:C# Port.GetReceivers方法的具体用法?C# Port.GetReceivers怎么用?C# Port.GetReceivers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Port
的用法示例。
在下文中一共展示了Port.GetReceivers方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Cleanup
public void Cleanup()
{
IPortReceive pa = new Port <int> ();
IPortReceive pb = new Port <string> ();
ITask task = new Task<int, string> ((i, s) => { });
var mr = new MultipleItemReceiver (task, pa, pb);
var dq = new SerialDispatchQueue ();
mr.TaskQueue = dq;
mr.Execute ();
Assert.AreEqual (1, pa.GetReceivers ().Length, "#1");
Assert.AreEqual (1, pb.GetReceivers ().Length, "#2");
mr.Cleanup ();
Assert.AreEqual (0, pa.GetReceivers ().Length, "#3");
Assert.AreEqual (0, pb.GetReceivers ().Length, "#4");
Assert.AreEqual (0, pa.ItemCount, "#5");
Assert.AreEqual (0, pb.ItemCount, "#6");
}
示例2: UnRegisterReceiverChangesGetReceivers
public void UnRegisterReceiverChangesGetReceivers()
{
IPortReceive ipr = new Port<int> ();
ReceiverTask rt = new EvalTask (true);
Assert.AreEqual (0, ipr.GetReceivers ().Length, "#1");
ipr.RegisterReceiver (rt);
ipr.RegisterReceiver (rt);
Assert.AreEqual (2, ipr.GetReceivers ().Length, "#3");
ipr.UnregisterReceiver (rt);
Assert.AreEqual (1, ipr.GetReceivers ().Length, "#4");
ipr.UnregisterReceiver (rt);
Assert.AreEqual (0, ipr.GetReceivers ().Length, "#5");
}
示例3: ReceiverCanUnregisterOnEvaluate
public void ReceiverCanUnregisterOnEvaluate()
{
IPortReceive p = new Port<int> ();
var rec = new WeirdReceiver (p);
Assert.AreEqual (1, p.GetReceivers ().Length, "#1");
((IPort)p).PostUnknownType (10);
Assert.AreEqual (0, p.GetReceivers ().Length, "#2");
}
示例4: ConstructorSideEffects
public void ConstructorSideEffects()
{
int cnt = 0;
IPortReceive pa = new Port <int> ();
IPortReceive pb = new Port <string> ();
var mr = new MultipleItemReceiver (Arbiter.FromHandler (() => { ++cnt; }), pa, pb);
Assert.AreEqual (0, pa.GetReceivers ().Length, "#1");
Assert.AreEqual (0, pb.GetReceivers ().Length, "#2");
Assert.AreEqual (0, cnt, "#3");
}
示例5: ExecutePersistent
public void ExecutePersistent()
{
int cnt = 0;
IPortReceive pa = new Port <int> ();
IPortReceive pb = new Port <string> ();
var mr = new MultipleItemReceiver (Arbiter.FromHandler (() => { ++cnt; }), pa, pb);
var dq = new SerialDispatchQueue ();
mr.TaskQueue = dq;
mr.State = ReceiverTaskState.Persistent;
Assert.AreEqual (0, pa.GetReceivers ().Length, "#1");
Assert.AreEqual (0, pb.GetReceivers ().Length, "#2");
mr.Execute ();
Assert.AreEqual (1, pa.GetReceivers ().Length, "#3");
Assert.AreEqual (1, pb.GetReceivers ().Length, "#4");
Assert.AreEqual (ReceiverTaskState.Onetime, pa.GetReceivers ()[0].State, "#5");
}
示例6: Execute2
public void Execute2()
{
int cnt = 0;
IPortReceive pa = new Port <int> ();
IPortReceive pb = new Port <string> ();
ITask task = new Task<int, string> ( (i, s) => { cnt += i + s.Length; });
var mr = new MultipleItemReceiver (task, pa, pb);
var dq = new SerialDispatchQueue ();
mr.TaskQueue = dq;
mr.Execute ();
var a = (Port<int>)pa;
var b = (Port<string>)pb;
a.Post (10);
Assert.AreEqual (0, pa.ItemCount, "#1");
Assert.AreEqual (0, cnt, "#2");
b.Post ("hello");
Assert.AreEqual (15, cnt, "#3");
//it's a one time thing
Assert.AreEqual (0, pa.GetReceivers ().Length, "#4");
Assert.AreEqual (0, pb.GetReceivers ().Length, "#5");
a.Post (1);
Assert.AreEqual (15, cnt, "#6");
b.Post ("x");
Assert.AreEqual (15, cnt, "#7");
}