Hi all,

I’m using FMOD in my C# application which plays music. The problem is when I want to fire an event at the end of the current track.

Here is how I do:

I declare:

[code:1g7455j3]public delegate void OnEndTrackEvent(object sender, EventArgs e);
public event OnEndTrackEvent OnEndTrack;[/code:1g7455j3]

During the initialization I use,

[code:1g7455j3]channelCallback = new CHANNEL_CALLBACK(OnEndMusic);[/code:1g7455j3]

And here is the event:

[code:1g7455j3]public RESULT OnEndMusic(IntPtr channelraw, FMOD.CHANNEL_CALLBACKTYPE type, int command, uint commanddata1, uint commanddata2)
if (EndMusic != null)
EndMusic(this.trackPath, new EventArgs());
this.OnEndTrack(this, new EventArgs());
return RESULT.OK;

In my main form, I register on the OnEndTrack event, and I would like to do something with my GUI:

[code:1g7455j3] void player_OnEndTrack(object sender, EventArgs e)
this.mainWindow.playPauseButton.IsEnabled = false;

The problem is I got an InvalidOperationException ("the caller thread can’t access this object because it has been created by another thread").
because it seems that the event is fired by a thread that FMOD created.

Do you have any idea how I can fix this issue ?


  • You must to post comments
Showing 0 results
Your Answer

Please first to submit.