Skip to content

Commit

Permalink
Merge pull request #2 from Vjacheslaw/master-v2
Browse files Browse the repository at this point in the history
Bug fix:
  • Loading branch information
WaldemarCoding authored Apr 7, 2020
2 parents 95ab84f + e6101f6 commit 63927e8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
17 changes: 14 additions & 3 deletions Src/ToastNotifications/Display/NotificationsDisplaySupervisor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ private void InternalClose(INotification notification)
UpdateWindowPosition();
}

public INotification CreateNotification<T>(Func<T> createNotificationFunc)
where T : INotification
{
return
(T)_dispatcher.Invoke(createNotificationFunc);
}

private void Dispatch(Action action)
{
_dispatcher.Invoke(action);
Expand Down Expand Up @@ -120,9 +127,13 @@ private void CloseNotification(INotification notification)
{
if (notification != null)
{
notification.DisplayPart.OnClose();
DelayAction.Execute(TimeSpan.FromMilliseconds(300),
() => _window?.CloseNotification(notification.DisplayPart),
DelayAction.Execute(
TimeSpan.FromMilliseconds(300),
() =>
{
notification.DisplayPart.OnClose();
_window?.CloseNotification(notification.DisplayPart);
},
_dispatcher);
}
}
Expand Down
4 changes: 3 additions & 1 deletion Src/ToastNotifications/Notifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ public void Notify<T>(Func<T> createNotificationFunc)
where T: INotification
{
Configure();
_lifetimeSupervisor.PushNotification(createNotificationFunc());
var notification = _displaySupervisor.CreateNotification(createNotificationFunc);

_lifetimeSupervisor.PushNotification(notification);
}

private void Configure()
Expand Down

0 comments on commit 63927e8

Please sign in to comment.