Unsubscribing from VirtualDataCollection.ItemsLoading

4 posts, 0 answers
  1. Vitalii
    Vitalii avatar
    104 posts
    Member since:
    Jul 2013

    Posted 21 Aug 2013 Link to this post

    I just noticed, that something is wrong with unsubscribing.

    Trying to divide large problem into smaller pieces.

    Lets start from the very beginning.
    I have a page with products categories A, and page with products list B (which obviously depends on category).
    In my case, while navigating from A to B, i'm sending parameter in navigation string.
    That means, i cant allow VirtualDataCollection to raise ItemsLoading event before OnNavigatedTo();

    So, i'm unsubscribing it in OnNavigatedFrom()

    public void OnNavigatedFrom()
            { 
                VirtualDataCollection.ItemsLoading -= VirtualDataCollectionOnItemsLoading;
                VirtualDataCollection.Clear();
     
                Cleanup();
            }
    Aaand subscribe in OnNavigatedTo()
    public void OnNavigatedTo()
            {
                VirtualDataCollection.ItemsLoading += VirtualDataCollectionOnItemsLoading;
            }

    However, something is going on wrong: when i'm visiting page second time, ItemsLoading is called several times with the same parameters.
    Can you check that?
  2. Deyan
    Admin
    Deyan avatar
    2039 posts

    Posted 21 Aug 2013 Link to this post

    Hello Vitalii,

    Thanks for writing.

    Since I do not have many details about the scenario, my first step would be to check if the ItemsLoading event has already been handled before subscribing for it again. Or simply unsubscribe from it each time you subscribe for it.

    If this resolves the problem what have caused it would be multiple subscription for it by providing the same handler.

    Regards,
    Deyan
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINDOWS PHONE 7.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. DevCraft banner
  4. Vitalii
    Vitalii avatar
    104 posts
    Member since:
    Jul 2013

    Posted 21 Aug 2013 Link to this post

    Well, this is a bit isolated case, so we can discuss it without sample project.
    The thing is that I'm subscribing only once, when navigatingTo page, and unsybscribe also once, when navigatingFrom page.
    However, when I'm visiting page for a second time, event isrising twice. Second time, callstack is quite strange, looking like it is called from other thread.
  5. Deyan
    Admin
    Deyan avatar
    2039 posts

    Posted 21 Aug 2013 Link to this post

    Hi Vitalii,

    Thanks for writing back.

    It seems what happens is somehow related to your particular scenario.
    Please make sure to include the scenario in the sample project we have agreed upon and we will review it.

    Regards,
    Deyan
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINDOWS PHONE 7.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top