Ensure notification posts are always scheduled to local thread

Posts can be triggered by Logger.Log events which are not guaranteed to be on the update thread.
This commit is contained in:
Dean Herbert 2017-07-28 15:03:08 +09:00
parent f705589bf2
commit 02a04afb29
1 changed files with 11 additions and 8 deletions

View File

@ -72,17 +72,20 @@ private void load()
public void Post(Notification notification)
{
State = Visibility.Visible;
Schedule(() =>
{
State = Visibility.Visible;
++runningDepth;
notification.Depth = notification.DisplayOnTop ? runningDepth : -runningDepth;
++runningDepth;
notification.Depth = notification.DisplayOnTop ? runningDepth : -runningDepth;
var hasCompletionTarget = notification as IHasCompletionTarget;
if (hasCompletionTarget != null)
hasCompletionTarget.CompletionTarget = Post;
var hasCompletionTarget = notification as IHasCompletionTarget;
if (hasCompletionTarget != null)
hasCompletionTarget.CompletionTarget = Post;
var ourType = notification.GetType();
sections.Children.FirstOrDefault(s => s.AcceptTypes.Any(accept => accept.IsAssignableFrom(ourType)))?.Add(notification);
var ourType = notification.GetType();
sections.Children.FirstOrDefault(s => s.AcceptTypes.Any(accept => accept.IsAssignableFrom(ourType)))?.Add(notification);
});
}
protected override void PopIn()