本文整理汇总了C#中IMessage.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# IMessage.Execute方法的具体用法?C# IMessage.Execute怎么用?C# IMessage.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMessage
的用法示例。
在下文中一共展示了IMessage.Execute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PutMessage
public static void PutMessage(IMessage message)
{
if (JobContext.IsJob)
{
JobContext.MessageQueue.PutMessage(message);
}
else
{
message.Execute();
}
}
示例2: AddMessageAndWait
/// <summary>
/// Adds the given message to the map's message queue and does not return
/// until the message is processed.
/// </summary>
/// <remarks>Make sure that the map is running before calling this method.</remarks>
/// <remarks>Must not be called from the map context.</remarks>
public void AddMessageAndWait(bool allowInstantExecution, IMessage msg)
{
if (allowInstantExecution && IsInContext)
{
msg.Execute();
}
else
{
EnsureNoContext();
// to ensure that we are not exiting in the current message-loop, add an updatable
// which again registers the message
var updatable = new SimpleUpdatable();
updatable.Callback = () => AddMessage(new Message(() =>
{
msg.Execute();
lock (msg)
{
Monitor.PulseAll(msg);
}
UnregisterUpdatable(updatable);
}));
lock (msg)
{
RegisterUpdatableLater(updatable);
// int delay = this.GetWaitDelay();
Monitor.Wait(msg);
// Assert.IsTrue(added, string.Format(debugMsg, args));
}
}
}