# Timeline callback and main thread communication

**URL:** https://qa.fmod.com/t/timeline-callback-and-main-thread-communication/14984
**Category:** Unity
**Created:** [August 26, 2019, 1:59pm UTC](https://qa.fmod.com/t/timeline-callback-and-main-thread-communication/14984 "2019-08-26T13:59:20Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![deathbypixel](https://avatars.discourse-cdn.com/v4/letter/d/ec9cab/32.png) [@deathbypixel](https://qa.fmod.com/u/deathbypixel)
#### Post date: [August 26, 2019, 1:59pm UTC](https://qa.fmod.com/t/timeline-callback-and-main-thread-communication/14984/1 "2019-08-26T13:59:20Z")

</div>

Hi!

I’ve set up a timeline callback per beat as such  
myInstance.setCallback(beatCallback, FMOD.Studio.EVENT\_CALLBACK\_TYPE.TIMELINE\_BEAT | FMOD.Studio.EVENT\_CALLBACK\_TYPE.TIMELINE\_MARKER);

and the callback signature

[AOT.MonoPInvokeCallback(typeof(FMOD.Studio.EVENT\_CALLBACK))]  
static FMOD.RESULT TestEventCallback(FMOD.Studio.EVENT\_CALLBACK\_TYPE type, FMOD.Studio.EventInstance instance, IntPtr parameterPtr)

Now I am checking some input (main thread) and would like to read some data in this callback thread. (I’m assuming the callback will be on a different thread) I’m not sure how, if at all, I can communcate or pass some data from my main thread (or monobehavior) to a callback or vice versa. Is there a pattern or a best practise here? My use case is that I want to react to things happening on a beat, logic that needs to be performed in monobehaviors.

Thanks!

---

<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: [September 2, 2019, 5:46am UTC](https://qa.fmod.com/t/timeline-callback-and-main-thread-communication/14984/2 "2019-09-02T05:46:58Z")

</div>

We have a couple of examples that use callbacks, the [Timeline example](https://www.fmod.com/resources/documentation-unity?version=2.0&page=examples-timeline-callbacks.html) uses the information from the callback by passing information through the `EventInstance.setUserData`.
