0
I have a form that is not the main form of the program. I am using Libvlc for C# for media playback in this form, so I have a Mediaplayer component. I’m dealing with the Mediaplayer_stopped event as in the code below:
private void MediaPlayer_Stopped(object sender, EventArgs e){
this.Close();
}
My intention is to close the current form when Media Player assumes the status of stopped. However, when using this.Close()
in this context, the form which is what I want to achieve is not referenced. The error I get when trying to execute the above code is:
System.InvalidOperationException: 'Operação de thread inválida: controle' Player 'acessado de um thread diferente daquele em que foi criado.'
How can I close the form in this case?