/// <summary> /// Gets the result. This is called internally by the async shit. /// </summary> public T?GetResult() { bool failed = false; if (!utils.IsAPICallCompleted(call, ref failed) || failed) { return(null); } var t = default(T); var size = t.DataSize; var ptr = Marshal.AllocHGlobal(size); try { if (!utils.GetAPICallResult(call, ptr, size, (int)t.CallbackType, ref failed) || failed) { Dispatch.OnDebugCallback?.Invoke(t.CallbackType, "!GetAPICallResult or failed", server); return(null); } Dispatch.OnDebugCallback?.Invoke(t.CallbackType, Dispatch.CallbackToString(t.CallbackType, ptr, size), server); return((T)Marshal.PtrToStructure(ptr, typeof(T))); } finally { Marshal.FreeHGlobal(ptr); } }