Best way Disposing / Stoping DispatcherTimer when you leave a Page RRS feed

  • Question

  • Hello,
    I would like to know whats the best way of disposing DispatcherTimer. So here is my scenario:

    I 'm using DispatcherTimer to handle some events on every page. When I leave a page the DispatcherTimer continues to run and that is bad. DispatcherTimer is Initialized in the Page Constructor so when i return in the page it resets.

    So i though adding this code when i leave the page:

    protected override void OnNavigatedFrom(NavigationEventArgs e)
                dispatcherTimer = null;

    Should i also add GC.Collect(); after null?

    Sorry if my English is bad,


    Wednesday, August 6, 2014 8:25 AM


All replies