本文整理匯總了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);
}