You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Added UiSystem.EnqueueAction to do work synchronously next time the ui system updates
- Fixed TextField EnterReceiver not allowing element addition or removal in
@@ -249,6 +251,12 @@ public override void Update(GameTime time) {
249
251
this.stopwatch.Restart();
250
252
251
253
this.Controls.Update();
254
+
lock(this.nextUpdateActionsLock){
255
+
while(this.nextUpdateActions.Count>0){
256
+
varnext=this.nextUpdateActions.Dequeue();
257
+
next.Action.Invoke(this,next.ActionObject);
258
+
}
259
+
}
252
260
for(vari=this.rootElements.Count-1;i>=0;i--)
253
261
this.rootElements[i].Element.Update(time);
254
262
@@ -332,6 +340,17 @@ public RootElement Get(string name) {
332
340
returnindex<0?null:this.rootElements[index];
333
341
}
334
342
343
+
/// <summary>
344
+
/// Enqueues the given <paramref name="action"/> (optionally with the given <paramref name="actionObject"/> attached) to be executed the next time <see cref="Update"/> is called, before all of this ui system's elements are updated.
345
+
/// This method is thread-safe, meaning actions can be enqueued from other threads (for example, after downloading content to display) and they will be executed on the main thread.
346
+
/// </summary>
347
+
/// <param name="action">The action to enqueue.</param>
348
+
/// <param name="actionObject">An optional object to attach to the action, which will be passed as the second parameter to <paramref name="action"/>.</param>
0 commit comments