本文整理汇总了C#中EventSource.FireEvent方法的典型用法代码示例。如果您正苦于以下问题:C# EventSource.FireEvent方法的具体用法?C# EventSource.FireEvent怎么用?C# EventSource.FireEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventSource
的用法示例。
在下文中一共展示了EventSource.FireEvent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WhenDetached_ThenDoesNotInvokeCallbackOnEvent
public void WhenDetached_ThenDoesNotInvokeCallbackOnEvent()
{
var instance = this;
var sender = new EventSource();
var invoked = false;
var weakHandler =
new WeakEventHandler<WeakEventListenerFixture, object, EventArgs>(
instance,
(i, s, e) =>
{
invoked = true;
},
handler => { sender.Event -= handler.OnEvent; });
sender.Event += weakHandler.OnEvent;
weakHandler.Detach();
sender.FireEvent(new EventArgs());
Assert.IsFalse(invoked);
}
示例2: WhenAttachedToAnEvent_ThenInvokesCallbackOnEvent
public void WhenAttachedToAnEvent_ThenInvokesCallbackOnEvent()
{
var instance = this;
var sender = new EventSource();
var args = new EventArgs();
var invoked = false;
var weakHandler =
new WeakEventHandler<WeakEventListenerFixture, object, EventArgs>(
instance,
(i, s, e) =>
{
Assert.AreSame(this, i);
Assert.AreSame(sender, s);
Assert.AreSame(args, e);
invoked = true;
},
handler => { sender.Event -= handler.OnEvent; });
sender.Event += weakHandler.OnEvent;
sender.FireEvent(args);
Assert.IsTrue(invoked);
}
示例3: WhenInstanceIsNull_ThenHandlerIsDetached
public void WhenInstanceIsNull_ThenHandlerIsDetached()
{
WeakEventListenerFixture instance = null;
var sender = new EventSource();
var invoked = false;
var detached = false;
var weakHandler =
new WeakEventHandler<WeakEventListenerFixture, object, EventArgs>(
instance,
(i, s, e) =>
{
invoked = true;
},
handler =>
{
sender.Event -= handler.OnEvent;
detached = true;
});
sender.Event += weakHandler.OnEvent;
sender.FireEvent(new EventArgs());
Assert.IsFalse(invoked);
Assert.IsTrue(detached);
}
示例4: WhenDetachedWithNullDetachAction_ThenInvokesCallbackOnEvent
public void WhenDetachedWithNullDetachAction_ThenInvokesCallbackOnEvent()
{
var instance = this;
var sender = new EventSource();
var invoked = false;
var weakHandler =
new WeakEventHandler<WeakEventListenerFixture, object, EventArgs>(
instance,
(i, s, e) =>
{
invoked = true;
},
null);
sender.Event += weakHandler.OnEvent;
weakHandler.Detach();
sender.FireEvent(new EventArgs());
Assert.IsTrue(invoked);
}