views:

165

answers:

1

Hi...

I get the "cross-thread operation not valid" here:

if ( vlc.State == VlcPlayerControlState.PLAYING )
        {
            if ( vlc.InvokeRequired )
            {
                vlc.Invoke( new MediaPlayerNoParameterDelegate( vlc.Stop ) );
            }
            else
            {
                vlc.Stop(); // debugger points here
            }
        }

Debugging shows me that vlc doesn't require invoking. but the thread from which this is accessed is different from the thread it was created on.

I'm using the libvlc.net wrapper to play sound, but the problem should not be there. How can I get rid of this exception?

I'm using threading not backgroundworker.

Thank you!

+1  A: 

It sounds like this is a bug in the libvlc.net wrappers.

My suggestion would be to just always call vlc.Invoke(...). You'll suffer a (small) performance hit when the invoke is truly not required, but if you're doing this from a separate thread, it will always be required anyways.

Reed Copsey