ICommentEvent runs TWICE in ONE comment
I have these code, according to document from sitefinity:
_________________________________________________________
protected void Application_Start(object sender, EventArgs e)
Bootstrapper.Initialized += new EventHandler<ExecutedEventArgs>(Bootstrapper_Initialized);
_________________________________________________________
public void Bootstrapper_Initialized(object sender, ExecutedEventArgs args)
if (args.CommandName == "Bootstrapped")
EventHub.Subscribe<ICommentEvent>(evt => CommentsEvent.CommentEventHandler(evt));
_________________________________________________________
and the handler:
_________________________________________________________
public static void CommentEventHandler(ICommentEvent evt)
// My code here
_________________________________________________________
The problem is this handler always runs twice when a comment event happens (post a comment or approve a comment).
Could you please tell me why this happens and any possible way to avoid this? (I don't believe static boolean is a good idea).
Thanks
Hello,
Can you please try to use the below sample code which will execute only once after a comment has been created:
protected
void
Bootstrapper_Initialized(
object
sender, Telerik.Sitefinity.Data.ExecutedEventArgs e)
if
(e.CommandName ==
"Bootstrapped"
)
EventHub.Subscribe<ICommentCreatedEvent>(evt => CommentsEventHandler(evt));
public
void
CommentsEventHandler(ICommentCreatedEvent eventInfo)
// your custom code
Thanks Sabrie.
I tried this before and the problem is this handler doesn't catch event when i publish a comment (from sitefinity back-end).
Any solutions?
Any solution for this yet?