# Stopping U3D in the callback will get stuck

**URL:** <https://qa.fmod.com/t/stopping-u3d-in-the-callback-will-get-stuck/14648>\
**Category:** Unity\
**Created:** [May 6, 2019, 11:45am UTC](https://qa.fmod.com/t/stopping-u3d-in-the-callback-will-get-stuck/14648 "2019-05-06T11:45:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![NICKS](https://avatars.discourse-cdn.com/v4/letter/n/4af34b/32.png) [@NICKS](https://qa.fmod.com/u/NICKS)\
**Post date:** [May 6, 2019, 11:45am UTC](https://qa.fmod.com/t/stopping-u3d-in-the-callback-will-get-stuck/14648/1 "2019-05-06T11:45:03Z")

</div>

I don’t know how to solve this problem. I’ve had very short access to this plug-in. Now I want to play several music sequentially, and now I save it in a list. (Forgive me for not knowing how to use this plug-in regularly, if you have a better way, I hope you can tell me), and then use callback monitoring, like this [dialogue Callback, EVENT\_CALLBACK\_TYPE.DESTROYED]] It works well, but when I close it Unity3D gets stuck before the callback event is executed. My English is poor. I’m sorry.

FMOD.Studio.EVENT\_CALLBACK dialogueCallback = new FMOD.Studio.EVENT\_CALLBACK(DialogueEventCallback);

static FMOD.RESULT DialogueEventCallback(FMOD.Studio.EVENT\_CALLBACK\_TYPE type, FMOD.Studio.EventInstance instance, IntPtr parameterPtr)  
{  
Debug.Log(“SAudioDataLoadState”);  
BgMisicEntity.GetInstance().PlayMusic(“event:/down2D”);  
return RESULT.OK;  
}

public void PlayMusic(string audioName)  
{  
\_bgmList = new List() { audioName };  
\_eventInstance.stop(FMOD.Studio.STOP\_MODE.IMMEDIATE);  
\_eventInstance = RuntimeManager.CreateInstance(\_bgmList[0]);

```
_eventInstance.setCallback(dialogueCallback, EVENT_CALLBACK_TYPE.DESTROYED);

_eventInstance.start();
_eventInstance.release();

```

}

Now when I execute PlayMusic, the sound will be played back and forth, and when I stop running, Unity3D will be stuck.

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [May 10, 2019, 4:40am UTC](https://qa.fmod.com/t/stopping-u3d-in-the-callback-will-get-stuck/14648/2 "2019-05-10T04:40:31Z")

</div>

Have a look at our [Timeline Callbacks](https://fmod.com/resources/documentation-unity?version=2.0&page=examples-timeline-callbacks.html) example, make sure you are freeing any pinned memory. Most platforms will also require `[AOT.MonoPInvokeCallback(typeof(FMOD.Studio.EVENT_CALLBACK))]` attribute on he callback function.

---

<div class="post-metadata">

**Author:** ![NICKS](https://avatars.discourse-cdn.com/v4/letter/n/4af34b/32.png) [@NICKS](https://qa.fmod.com/u/NICKS)\
**Post date:** [May 10, 2019, 6:23am UTC](https://qa.fmod.com/t/stopping-u3d-in-the-callback-will-get-stuck/14648/3 "2019-05-10T06:23:21Z")

</div>

thank you for your help
