/// <summary> /// Enqueues a command for the tracking thread using a JSON string. /// </summary> /// <remarks> /// <para> /// The command gets processed asynchronously by the tracking thread and /// a callback will called once after the processing has finished. /// </para> /// <para> /// You need to make sure, that the JSON string has the expected format. /// Therefore you might want to use the <see cref="VLWorker.PushCommand"/> /// functions instead. This function will ensure that the command will be /// pushed as expected. /// </para> /// </remarks> /// <param name="jsonString"> /// The command with all necessary data as JSON string. /// </param> /// <param name="callback"> /// Callback, which will be called inside <see cref="ProcessCallbacks"/> /// after the command was processed. /// </param> /// <param name="clientData"> /// The callback function will be called with the given pointer value. /// </param> /// <returns> /// <c>true</c>, if the command was enqueue successfully; /// <c>false</c> otherwise (usually some JSON syntax error). /// </returns> public bool PushJsonCommand(string jsonString, JsonStringCallback callback, IntPtr clientData) { if (this.disposed) { throw new ObjectDisposedException("VLWorker"); } return(vlWorker_PushJsonCommand( this.handle, jsonString, callback, clientData)); }
/// <summary> /// Enqueues a command for the tracking thread. /// </summary> /// <remarks> /// <para> /// The command gets processed asynchronously by the tracking thread and /// a callback will called once after the processing has finished. /// </para> /// <para> /// The different commands are defined inside the /// <see cref="VLWorkerCommands"/> namespace. /// </para> /// </remarks> /// <param name="cmd"> /// The command object. /// </param> /// <param name="callback"> /// Callback, which will be called inside <see cref="ProcessCallbacks"/> /// after the command was processed. /// </param> /// <param name="clientData"> /// The callback function will be called with the given pointer value. /// </param> /// <returns> /// <c>true</c>, if the command was enqueue successfully; /// <c>false</c> otherwise. /// </returns> public bool PushCommand(VLWorkerCommands.CommandBase cmd, JsonStringCallback callback, IntPtr clientData) { if (this.disposed) { throw new ObjectDisposedException("VLWorker"); } return(vlWorker_PushJsonCommand(this.handle, VLJsonUtility.ToJson(cmd), callback, clientData)); }
private static extern bool vlWorker_PushJsonCommand(IntPtr worker, [MarshalAs(UnmanagedType.LPStr)] string jsonString, [MarshalAs(UnmanagedType.FunctionPtr)] JsonStringCallback callback, IntPtr clientData);