/// <summary> /// Retrieve a haptic definition file from a given path asynchronously /// </summary> /// <param name="path">The path to the raw asset</param> /// <param name="callback">The callback to be executed upon receiving the file</param> private void GetHapticDefinitionAsync(string path, HapticDefinitionCallback callback) { AsyncMethodCaller caller = new AsyncMethodCaller(_assetTool.GetHapticDefinitionFile); IAsyncResult r = caller.BeginInvoke(path, delegate(IAsyncResult iar) { AsyncResult result = (AsyncResult)iar; AsyncMethodCaller caller2 = (AsyncMethodCaller)result.AsyncDelegate; HapticDefinitionCallback hdfCallback = (HapticDefinitionCallback)iar.AsyncState; HapticDefinitionFile hdf = caller2.EndInvoke(iar); hdfCallback(hdf); }, callback); }
/// <summary> /// Retrieve a haptic definition file from a given path asynchronously /// </summary> /// <param name="path">The path to the raw asset</param> /// <param name="HDFSuccessCallback">The callback to be executed upon receiving the file</param> /// <param name="failCallback">The callback to be executed if we encounter an exception along the way - invalid files, junk content, etc</param> private void GetHapticDefinitionAsync(string path, HapticDefinitionCallback HDFSuccessCallback, ExceptionCallback failCallback) { AsyncMethodCaller caller = new AsyncMethodCaller(_assetTool.GetHapticDefinitionFile); /*IAsyncResult r = */ caller.BeginInvoke(path, delegate(IAsyncResult iar) { AsyncResult result = (AsyncResult)iar; AsyncMethodCaller caller2 = (AsyncMethodCaller)result.AsyncDelegate; HapticDefinitionCallback hdfCallback = (HapticDefinitionCallback)iar.AsyncState; try { HapticDefinitionFile hdf = caller2.EndInvoke(iar); hdfCallback(hdf); } catch (Exception whatTheHellMicrosoft) { Debug.LogError("Async Delegate Error getting haptic definition at path [" + path + "]\n" + whatTheHellMicrosoft.Message); failCallback(whatTheHellMicrosoft); } }, HDFSuccessCallback); }