# (C#) Calling EventInstance::setCallback with various callbackmasks results in only the last one working

**URL:** <https://qa.fmod.com/t/c-calling-eventinstance-setcallback-with-various-callbackmasks-results-in-only-the-last-one-working/12610>\
**Category:** FMOD Studio\
**Created:** [July 23, 2016, 4:07am UTC](https://qa.fmod.com/t/c-calling-eventinstance-setcallback-with-various-callbackmasks-results-in-only-the-last-one-working/12610 "2016-07-23T04:07:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![02leeken](https://avatars.discourse-cdn.com/v4/letter/0/b19c9b/32.png) [@02leeken](https://qa.fmod.com/u/02leeken)\
**Post date:** [July 23, 2016, 4:07am UTC](https://qa.fmod.com/t/c-calling-eventinstance-setcallback-with-various-callbackmasks-results-in-only-the-last-one-working/12610/1 "2016-07-23T04:07:14Z")

</div>

Hello,

I’ve been using FMOD Studio for my latest project, and I noticed an odd quirk with the EventInstance::setCallback method. Quick disclaimer, I’m using the C# implementation, so I’m not sure if that changes anything.

Anyway, I noticed that whenever I run the EventInstance::setCallback method in succession, only the latest callback gets assigned, regardless of the callback mask I use. So for example, I wanted a callback/delegate to trigger when an instance is created, and another one to trigger when the instance is stopped. But in this code:

instance.setCallback(m\_delegate1, EVENT\_CALLBACK\_TYPE.STOPPED);  
instance.setCallback(m\_delegate2, EVENT\_CALLBACK\_TYPE.CREATED);

only the EVENT\_CALLBACK\_TYPE.CREATED callback will register. Conversely, if I switch them around and have the STOPPED callback the last line, only the STOPPED callback will register. The only way I can get this to work is if I get one of those lines of code to be called an update after the other one.

I’m not sure if my implementation is incorrect, or if this is undesired behaviour, but I thought I’d bring it up.

Any insight into this is much appreciated.

Thanks,

Kenny

---

<div class="post-metadata">

**Author:** ![nick1](https://avatars.discourse-cdn.com/v4/letter/n/47e85d/32.png) [@nick1](https://qa.fmod.com/u/nick1)\
**Post date:** [July 24, 2016, 11:47pm UTC](https://qa.fmod.com/t/c-calling-eventinstance-setcallback-with-various-callbackmasks-results-in-only-the-last-one-working/12610/2 "2016-07-24T23:47:05Z")

</div>

There can only be one callback delegate registered per event. If you wish to receive multiple types of events **OR** them together.

```
instance.setCallback(m_delegate1, EVENT_CALLBACK_TYPE.STOPPED | EVENT_CALLBACK_TYPE.CREATED);

```

The specific event that triggered the callback is passed as an argument.

---

<div class="post-metadata">

**Author:** ![02leeken](https://avatars.discourse-cdn.com/v4/letter/0/b19c9b/32.png) [@02leeken](https://qa.fmod.com/u/02leeken)\
**Post date:** [July 25, 2016, 2:50am UTC](https://qa.fmod.com/t/c-calling-eventinstance-setcallback-with-various-callbackmasks-results-in-only-the-last-one-working/12610/3 "2016-07-25T02:50:00Z")

</div>

Oh I see. Thank you for the answer.
