locked
UI Thread vs Tasks vs Binding vs Sealed/Dependency Object

    Question

  • Hi All

    I am dealing with this situation : downloading massive xml, parsing (DOM parser) and create objects in collection. Collection is connected with GridView with binding. Parsing is in arbitrary task but I have to Dispatcher->RunAsync every item creation and so because of basic class is DependencyObject (and so can't be created outsided of UI thread).

    I have serious performance problems with this and solution is far from user experience expected by Modern UI standards :-( Here is couple of questions :

    - if bindable interfaces (INofifyPropertyChanged) will be impemented in sealed class without DependencyObject, will it work on arbitrary task (with dispatching only property changes) ?

    - it looks that sometimes task ignore requested task_continuation_context and is started in current even when I request arbitrary (is there some doc about this ?) 

    - is there some way how to use "ref classes" ARC advantages without DependencyObject as parent (and his requirements to be created on UI thread) and with chance to create my own class tree with inheritances ?

    - do somebody know how MS sample http client running (STA/MTA ?) I have problems even without it but it looks worse with it :-) 

    I am starting be nervous, I have all code in tasks, arbitrary continuation context and application still not flow as it can :-(

    Monday, November 05, 2012 5:51 PM

All replies

  • small improvement

    If task (even arbitrary) doing something intensive, it will slow UI responsiveness. Adding wait(1); will change feel very rapidly (for those who remember - similar as forgotten waitfor... in Win32 message loop)

    create_task([] ()
    {}).then([] ()
    {
    while (true)
    {
    wait(1); <<THIS MAKES DIFFERENCE
    OutputDebugString(L"Tick\n");
    }


    },task_continuation_context::use_arbitrary());

    Tuesday, November 06, 2012 9:20 AM