Giter Site home page Giter Site logo

Deadlock in Pause() about flyleaf HOT 3 CLOSED

vers-one avatar vers-one commented on July 19, 2024
Deadlock in Pause()

from flyleaf.

Comments (3)

SuRGeoNix avatar SuRGeoNix commented on July 19, 2024 1

I do agree with you guys, that's the main reason of focusing in the next major version.
New threading, locking mechanisms with custom blocking collections using pulse/wait.

However, this is not related with this issue, this has to do with the library being also a view model and if you don't know your events in which thread are running you probably going to mess up. In your case Pause will call also your registered event PlaybackStopped so you could just unsubscribe it when you manually pause and then subscribe again.

from flyleaf.

coldays avatar coldays commented on July 19, 2024

The PlaybackStopped event has a warning in it's summary:
/// Warning: Uses Invoke and it comes from playback thread so you can't pause/stop etc. You need to use another thread if you have to.
Maybe it should say that it uses the main thread / GUI thread and maybe pause should warn that is uses the GUI thread as well.
Other than that, it looks like this deadlock is created by the example itself.

If you don't like to use BeginInvoke you can also call Pause from another Task.
A better "WPF" way to handle this is to create bindings to the player state directly instead of manually setting IsEnabled on the button.

from flyleaf.

umlx5h avatar umlx5h commented on July 19, 2024

As a side note, the amount of Thread.Sleeps in the library's code is a little bit concerning.

Probably BlockingCollection<T>, Channels instead of ConcurrentQueue<T> can be used instead
or use ConcurrentQueue<T> with Monitor.Wait, Pulse.

Sorry this has nothing to do with the issue, I am also wondering why Thread.Sleep is used so much.

from flyleaf.

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.