5
我們正試圖在Eventing Code中取消訂閱eventSubscripton。我們用下面的代碼SDL Tridion EventSubscription UnSubscribe Issue
[TcmExtension("EventHandlerExtension")]
public class EventHandler : TcmExtension, IDisposable
{
private EventSubscription componentSaveSubscription = null;
private EventSubscription componentPublishSubscription = null;
#region Public Methods
/// <summary>
/// Handle for Eventing System
/// </summary>
public EventHandler()
{
Subscribe();
}
/// <summary>
/// Subscribe Events
/// </summary>
public void Subscribe()
{
//News Article Page created when component Save
componentSaveSubscription = EventSystem.Subscribe<Component, SaveEventArgs>(OnComponentSavePost, EventPhases.TransactionCommitted);
//EventSystem.Subscribe<Component, SaveEventArgs>(OnComponentSavePost, EventPhases.TransactionCommitted);
componentPublishSubscription = EventSystem.Subscribe<Component, PublishOrUnPublishEventArgs>(OnComponentPublishOrUnPublishPost, EventPhases.TransactionCommitted);
//EventSystem.Subscribe<StructureGroup, PublishOrUnPublishEventArgs>(OnStructureGroupPublishInitiated, EventPhases.TransactionCommitted);
}
/// <summary>
/// IDisposable Implementation
/// </summary>
public void Dispose()
{
if (componentSaveSubscription != null) componentSaveSubscription.Unsubscribe();
if (componentPublishSubscription != null) componentPublishSubscription.Unsubscribe();
}}
我們所觀察到的是,一旦「{} EventSubsciption .Unsubscribe」之稱,事件會停止,這就是它應該工作的後續事件的工作。一旦事件系統相關的服務重新啓動,事件代碼就會按照預期的那樣進行工作,並且永遠不會爲後來的事件(它本應該工作的)調用。
當你的對象的'的Dispose()'方法被調用?據我所知,這應該只發生在處理程序運行的模塊關閉時(甚至可能還沒有)。 –
如果你不Dispose()它按預期工作?那麼停止處置? –