Reputation: 2803
Im trying to play an song then a person is calling my application. But then the mediaElement1.play();
is used i just get an The calling thread cannot access this object because a different thread owns it.
. I have tried to use threading. But then the problem just moves.
Best regard Morten Starck
Upvotes: 0
Views: 53
Reputation: 22011
Does this do the trick?
if (!mediaElement1.CheckAccess())
mediaElement1.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal,
(Action)delegate
{
mediaElement1.play();
});
Upvotes: 2