Chúng tôi đang cố gắng hủy đăng ký khỏi sự kiệnSubscripton trong Mã sự kiện của chúng tôi. Chúng tôi đang sử dụng đoạn mã sauSDL Tridion EventSubcription 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();
}}
Những gì chúng ta đã quan sát thấy là một khi “{} EventSubsciption .Unsubscribe” được gọi, eventing ngừng hoạt động cho các sự kiện tiếp theo mà nó là vụ phải làm việc. Khi các dịch vụ liên quan đến hệ thống sự kiện được khởi động lại, mã sự kiện hoạt động như dự kiến cho lần đầu tiên và không bao giờ được gọi cho các sự kiện tiếp theo (mà nó được cho là hoạt động).
Khi được đối tượng của bạn 'Dispose()' phương pháp được gọi? Theo tôi biết điều này sẽ chỉ xảy ra khi mô-đun mà trình xử lý chạy trong bị tắt (và thậm chí không có khả năng). –
Và nếu bạn không Dispose() nó hoạt động như mong đợi? Sau đó ngừng xử lý? –