Arrg, that can be true - I have so far (and lazy) only tested the ugly samples on vs2003.
You are right!
Whenever BASS callbacks are involved I should have used "this.Invoke(...)" or "this.BeginInvoke(...)" together with a global delegate to call asynchroniously a method in the main UI thread.
So please exchange the last method called "MetaSync" with the the following code which will use delegate callbacks instead and should work fine.
I am going to improve the samples in the next version ;-) THX
private void MetaSync(int handle, int channel, int data, int user)
{
// BASS_SYNC_META delivers a pointer to the metadata in data parameter...
if (data != 0)
{
// NOTE: this will just deliver the first meta data string!
// since the pointer given is typically a series of null-terminated strings!
string txt = Marshal.PtrToStringAnsi(new IntPtr( data ));
this.Invoke(new UpdateStatusDelegate(UpdateStatusDisplay), new object[] { txt });
}
// or alternatively use the TAG_INFO object
if ( _tagInfo.UpdateFromMETA( data, false ) )
{
this.Invoke(new UpdateTagDelegate(UpdateTagDisplay));
}
}
public delegate void UpdateTagDelegate();
private void UpdateTagDisplay()
{
this.textBoxAlbum.Text = _tagInfo.album;
this.textBoxArtist.Text = _tagInfo.artist;
this.textBoxTitle.Text = _tagInfo.title;
this.textBoxComment.Text = _tagInfo.comment;
this.textBoxGenre.Text = _tagInfo.genre;
this.textBoxYear.Text = _tagInfo.year;
}
public delegate void UpdateStatusDelegate(string txt);
private void UpdateStatusDisplay(string txt)
{
this.statusBar1.Text = txt;
}