18 May '13 - 20:42 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Reply  |  Print  
Author Topic: [.NET] Syncproc and GC  (Read 377 times)
smoodilo
Guest
« on: 13 May '12 - 20:04 »
Reply with quoteQuote

@Radio42

I think I have the known GC issue with calling a syncproc. I read this in the docs....

------------
NOTE: When you pass an instance of a callback delegate to one of the BASS functions, this delegate object will not be reference counted. This means .NET would not know, that it might still being used by BASS. The Garbage Collector might (re)move the delegate instance, if the variable holding the delegate is not declared as global. So make sure to always keep your delegate instance in a variable which lives as long as BASS needs it, e.g. use a global variable or member.
-------------

..... but I don't understand exactly what to do. What variable exactly should be declared gloabally?
Could you please explain a little more or show an example?








Logged
gnag
Posts: 160


« Reply #1 on: 13 May '12 - 23:50 »
Reply with quoteQuote

Just define your SYNCPROC like they do in the Documentation:

private SYNCPROC _mySync;
...
_mySync = new SYNCPROC(EndSync);
Bass.BASS_ChannelSetSync(_stream, BASSSync.BASS_SYNC_END | BASSSync.BASS_SYNC_MIXTIME,
                         0, _mySync, IntPtr.Zero);
...
private void EndSync(int handle, int channel, int data, IntPtr user)
{
  // the 'channel' has ended - jump to the beginning
  Bass.BASS_ChannelSetPosition(channel, 0L);
}

So the _mySync is the global variable in this example.

What Problem are you facing that makes you think its a Garbage Collection Problem?
Logged
smoodilo
Guest
« Reply #2 on: 14 May '12 - 07:33 »
Reply with quoteQuote

I get this error once in a while:

Managed Debugging Assistant 'CallbackOnCollectedDelegate' has detected a problem in 'C:\PROJECTS\bin\Debug\TEST.exe'.

The rest of the message is not in English so I won't bother anyone with it.
Logged
radio42
Posts: 4012


« Reply #3 on: 14 May '12 - 10:18 »
Reply with quoteQuote

PLease show your code which causes the exception to take a look at.
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines