mirror of
https://github.com/SK-la/osu-framework.git
synced 2026-03-15 03:20:30 +00:00
Add notes regarding using inline delegates with Scheduler.AddOnce
This commit is contained in:
@@ -429,6 +429,8 @@ namespace osu.Framework.Tests.Threading
|
||||
{
|
||||
classInvocations = 0;
|
||||
|
||||
// Note that while this works here (even with a capture), there's no guarantee that will always be the
|
||||
// case. As such it's always best to use a local function or private method.
|
||||
for (int i = 0; i < 10; i++)
|
||||
invokeInlineDelegateAction();
|
||||
|
||||
|
||||
@@ -368,7 +368,7 @@ namespace osu.Framework.Threading
|
||||
/// Adds a task which will only be run once per frame, no matter how many times it was scheduled in the previous frame.
|
||||
/// </summary>
|
||||
/// <remarks>The task will be run on the next <see cref="Update"/> independent of the current clock time.</remarks>
|
||||
/// <param name="task">The work to be done.</param>
|
||||
/// <param name="task">The work to be done. Avoid using inline delegates as they may not be cached, bypassing the once-per-frame guarantee.</param>
|
||||
/// <returns>Whether this is the first queue attempt of this work.</returns>
|
||||
public bool AddOnce(Action task)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user