本文整理汇总了C#中Actor.Send方法的典型用法代码示例。如果您正苦于以下问题:C# Actor.Send方法的具体用法?C# Actor.Send怎么用?C# Actor.Send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Actor
的用法示例。
在下文中一共展示了Actor.Send方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegisterSellers
private static void RegisterSellers(Actor auctioneer, int count)
{
for (int i = 0; i < count; i++)
{
string name = "Seller {0}".FormatWith(i);
var message = new RegisterSeller
{
Name = name
};
auctioneer.Send(message);
}
}
示例2: InvokeIncrementTenTimes
public void InvokeIncrementTenTimes()
{
ManualResetEvent handle = new ManualResetEvent(false);
Counter counter = new Counter();
Actor<Counter> actor = new Actor<Counter>(counter);
actor.Send(c => { for (int k=1; k<=10; k++) c.Increment(); handle.Set(); });
handle.WaitOne();
Assert.AreEqual(10, counter.Count);
}
示例3: InvokeIncrement
public void InvokeIncrement()
{
ManualResetEvent handle = new ManualResetEvent(false);
Counter counter = new Counter();
Actor<Counter> actor = new Actor<Counter>(counter);
actor.Send(c => { c.Increment(); handle.Set(); });
handle.WaitOne();
Assert.AreEqual(1, counter.Count);
}
示例4: InvokeIncrementInAnotherThread
public void InvokeIncrementInAnotherThread()
{
ManualResetEvent handle = new ManualResetEvent(false);
Thread thread = null;
Counter counter = new Counter();
Actor<Counter> actor = new Actor<Counter>(counter);
actor.Send(c => { c.Increment(); thread = Thread.CurrentThread; handle.Set(); });
handle.WaitOne();
Assert.AreEqual(1, counter.Count);
Assert.IsNotNull(thread);
Assert.AreNotSame(Thread.CurrentThread, thread);
}