none
Composite WPF -> Events Stop Firing RRS feed

  • General discussion

  • Hi there,

    I'm having the following problem problem: I'm using the EventAggregator to publish and subscribe some events to send information between some of my modules.

    The problem is that, for some reason, the events stop working after some period without any exception or problem... They simply stop working, by this I mean that my subscribers after some time don't capture the events fired, the number of events captured are not always equal, in a execution in can only capture 1 event and in the next it can be caught several events. I've tried everything I recall but without success.

    The code I use to publish an event is:

    <em>MenuClickParams Eparams = new MenuClickParams();<br> 
    Eparams.ClickButtonDescription = "CreateEvent";<br> 
    ConfiguratorContainer.EAggregator.GetEvent&lt;MenuClickEvent&gt;().Publish(Eparams);</em> 


    The code I use to subscribe to a event is:

    MenuClickEvent CreateEventEvent = ConfiguratorContainer.EAggregator.GetEvent&lt;MenuClickEvent&gt;();<br> 
    CreateEventEvent.Subscribe(CreateEventEventHandler, 
    ThreadOption.PublisherThread, false, e =&gt; e.ClickButtonDescription 
    == "CreateEvent"); 


    The MenuClickEvent Class is defined by:

    <em>public class MenuClickEvent : CompositeWpfEvent&lt;MenuClickParams&gt;{}</em> 



    And the MenuClickParams is defined by:

    <em>public class MenuClickParams<br>{<br>private string clickButtonDescription;<br><br> 
        public string ClickButtonDescription<br> 
        {<br> 
            get { return clickButtonDescription; }<br> 
            set { clickButtonDescription = value; }<br> 
        }<br> 
    }</em> 


    Any ideas of what I'm doing wrong? Or how can I solve this?

    Thanks in advance,
    Regards,
    Daniel Alves
    • Changed type Marco Zhou Tuesday, September 23, 2008 4:22 AM OP doesn't revert back
    Friday, September 12, 2008 11:25 AM

All replies


  • I don't want to hijack the post but in case it helps come up with an answer I'd just like to say I am having exactly the same issue while using the event aggregator with the composite application lib and await an answer with interest. I've included the relevant snippest of my code in case there is something in it that offers a clue to answer the OPs issue (and hopefully mine as a side effect :) )

    //event 
    public class MyEvent : CompositeWpfEvent<bool> 
    {} 
      
    // subscribing 
    _eventAggregator.GetEvent<MyEvent>().Subscribe(MyHandler, ThreadOption.UIThread); 
     
    // Publishing 
    MyEvent myEvent = _eventAggregator.GetEvent<MyEvent>(); 
    myEvent.Publish(true); 

    Monday, September 15, 2008 11:30 AM
  • Daniel,

    not sure if it is relevant to your issue, my problem was due to the fact that my object was being garbage collected even though it was subscribed to events. This it appears is an intentional behaviour for the CAL - "

    the CompositeWPFEvent<TPayload> class uses delegates rather than full .Net events for publishing to allow subscribers to be garbage collected even when they do not explicitly unsubscribe"

    http://msdn.microsoft.com/en-us/magazine/cc785479.aspx

    (Found this out when I put a breakpoint on PruneAndReturnStrategies() in EventBase in the CALib and it was stripping out my event because my 'action' was null.)

    hope it helps

    Trev
    Tuesday, September 16, 2008 2:44 PM
  • I don't use Composite WPF library, but if you are willing to send your ready-to-example test project to me, I might be willing to help you figure out what's going on.

    You could reach me at v-mazho at microsoft dot com.

    Thanks
    Thursday, September 18, 2008 7:45 AM
  • We are changing the issue type to “Comment” because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question” by clicking the "Options" link at the top of your post, and selecting "Change Type" menu item from the pop menu. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.

     

    Thank you!

    Tuesday, September 23, 2008 4:22 AM
  • Hi, I am also facing the same issue.did you resolve it??please suggest
    Friday, July 13, 2012 11:51 AM