Compare commits

...

1 Commits

Author SHA1 Message Date
qhy040404
5182fd8577 trigger gc after viewmodel dispose 2024-04-28 14:19:24 +08:00
2 changed files with 14 additions and 8 deletions

View File

@@ -104,6 +104,7 @@ internal class ScopedPage : Page
// Dispose the scope
pageScope.Dispose();
GC.Collect(GC.MaxGeneration, GCCollectionMode.Aggressive, true);
}
}
}

View File

@@ -25,7 +25,7 @@ internal sealed partial class DailyNoteNotificationOperation
private readonly ITaskContext taskContext;
private readonly IGameServiceFacade gameService;
private readonly BindingClient bindingClient;
private readonly IServiceScopeFactory serviceScopeFactory;
private readonly DailyNoteOptions options;
private readonly RuntimeOptions runtimeOptions;
@@ -58,6 +58,10 @@ internal sealed partial class DailyNoteNotificationOperation
}
else
{
using (IServiceScope scope = serviceScopeFactory.CreateScope())
{
BindingClient bindingClient = scope.ServiceProvider.GetRequiredService<BindingClient>();
Response<ListWrapper<UserGameRole>> rolesResponse = await bindingClient
.GetUserGameRolesOverseaAwareAsync(entry.User)
.ConfigureAwait(false);
@@ -68,6 +72,7 @@ internal sealed partial class DailyNoteNotificationOperation
attribution = roles.SingleOrDefault(r => r.GameUid == entry.Uid)?.ToString() ?? ToastAttributionUnknown;
}
}
}
ToastContentBuilder builder = new ToastContentBuilder()
.AddHeader(ToastHeaderIdArgument, SH.ServiceDailyNoteNotifierTitle, ToastHeaderIdArgument)