本文整理汇总了C#中EventSource.OpenOrCreate方法的典型用法代码示例。如果您正苦于以下问题:C# EventSource.OpenOrCreate方法的具体用法?C# EventSource.OpenOrCreate怎么用?C# EventSource.OpenOrCreate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventSource
的用法示例。
在下文中一共展示了EventSource.OpenOrCreate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EventSource
public void Given_an_event_source_when_a_object_is_retrieved_and_no_strong_reference_is_held_then_garbage_collection_of_retrieved_object_is_free_to_occur()
{
var es =
new EventSource(new NullPersistenceStrategy());
var finalized = false;
var ba = es.OpenOrCreate<BankAccountWithGcNotify>(new Guid("a2d06e1b-a311-45c7-9097-d288d61a8c33"));
ba.FinalizeCallback = () => finalized = true;
// ReSharper disable RedundantAssignment
ba = null;
// ReSharper restore RedundantAssignment
GC.Collect();
GC.WaitForPendingFinalizers();
// Note: This test will fail in NCrunch with default settings. You must turn off the "Analyse line execution times"
// function for this project only under the NCrunch -> Configuration screen.
Assert.That(finalized);
}