Giter Site home page Giter Site logo

Comments (4)

anaisbetts avatar anaisbetts commented on May 5, 2024

Also reading through the iOS code, I was curious why the work to load the image was being dispatched to the main thread.

Good question, might have to do some history digging

from splat.

bordoley avatar bordoley commented on May 5, 2024

Ps. I realize this would be a breaking API change, so probably 2.0 only.

from splat.

anaisbetts avatar anaisbetts commented on May 5, 2024

The main rationale is that if the code you are executing is already on a background thread or eventloop(wink) where you can block the thread safely, the cost of the context switch to the threadpool outweights the benefit of being async.

So the problem is, that on WinRT and WP8, you must dispatch to the UI thread to load images, it has to be async. However, I think these are two separate problems - something can be async but not necessarily always do a Task.Run. If someone were to contribute a cross-platform API called "IsOnUIThread" 😉, it would be trivial to implement bitmap loading s.t. it wouldn't always jump threads

from splat.

bordoley avatar bordoley commented on May 5, 2024

I'm not a fan of "IsOnUIThread" flag changing the behavior of a library call. Particularly for code that could block, I think the decision of whether a call should be async or not really needs to be explicitly decided by the caller based upon their performance criteria. For instance to play devils advocate to my use case, there may be scenarios where code running on a second event loop actually cannot block and the caller would prefer the use of the task pool and thread hop vs blocking the thread. A concrete example of this is a WPF app where different windows in the app have their own threads with their own dispatchers.

from splat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.