Esempio n. 1
0
 /// <summary>
 /// Schedules work to run on the given message loop. This may be called from
 /// any thread. Posted work will be executed in the order it was posted when
 /// the message loop is Run().
 ///
 /// The completion callback will be called with PPError.Ok as the "result"
 /// parameter if it is run normally. It is good practice to check for PP_OK
 /// and return early otherwise.
 ///
 /// The "required" flag on the completion callback is ignored. If there is an
 /// error posting your callback, the error will be returned from PostWork and
 /// the callback will never be run (because there is no appropriate place to
 /// run your callback with an error without causing unexpected threading
 /// problems). If you associate memory with the completion callback (for
 /// example, you're using the C++ CompletionCallbackFactory), you will need to
 /// free this or manually run the callback. See "Desctruction and error
 /// handling" above.
 ///
 ///
 /// You can call this function before the message loop has started and the
 /// work will get queued until the message loop is run. You can also post
 /// work after the message loop has exited as long as should_destroy was
 /// false. It will be queued until the next invocation of Run().
 /// </summary>
 /// <param name="action">An Action<PPError, T, U> that serves as completion callback to execute from the
 /// message loop that can be passed two objects to serve as user datas to be passed to the delegate.
 /// </param>
 /// <param name="delay">The number of milliseconds to delay execution of the given
 /// completion callback. Passing 0 means it will get queued normally and
 /// executed in order.
 /// </param>
 /// <returns></returns>
 public PPError PostWork <T, U>(Action <PPError, T, U> action, T userData1, U userData2, long delay = 0) =>
 (PPError)PPBMessageLoop.PostWork(this, new CompletionCallback <T, U>(
                                      new CompletionCallbackFunc <T, U>(action),
                                      userData1,
                                      userData2), delay);
Esempio n. 2
0
 /// <summary>
 /// Schedules work to run on the given message loop. This may be called from
 /// any thread. Posted work will be executed in the order it was posted when
 /// the message loop is Run().
 ///
 /// The completion callback will be called with PPError.Ok as the "result"
 /// parameter if it is run normally. It is good practice to check for PP_OK
 /// and return early otherwise.
 ///
 /// The "required" flag on the completion callback is ignored. If there is an
 /// error posting your callback, the error will be returned from PostWork and
 /// the callback will never be run (because there is no appropriate place to
 /// run your callback with an error without causing unexpected threading
 /// problems). If you associate memory with the completion callback (for
 /// example, you're using the C++ CompletionCallbackFactory), you will need to
 /// free this or manually run the callback. See "Desctruction and error
 /// handling" above.
 ///
 ///
 /// You can call this function before the message loop has started and the
 /// work will get queued until the message loop is run. You can also post
 /// work after the message loop has exited as long as should_destroy was
 /// false. It will be queued until the next invocation of Run().
 /// </summary>
 /// <param name="action">An Action that serves as completion callback to execute from the
 /// message loop.
 /// </param>
 /// <param name="delay">The number of milliseconds to delay execution of the given
 /// completion callback. Passing 0 means it will get queued normally and
 /// executed in order.
 /// </param>
 /// <returns></returns>
 public PPError PostWork(Action <PPError> action, long delay = 0) =>
 (PPError)PPBMessageLoop.PostWork(this,
                                  new CompletionCallback(new CompletionCallbackFunc(action))
                                  , delay);