清理引用,将NavigatorServices更改为使用Message来实现导航的切换
This commit is contained in:
@@ -1,37 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using PMSWPF.Message;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace PMSWPF.Services
|
||||
namespace PMSWPF.Services;
|
||||
|
||||
internal class DemoBackgroundService : BackgroundService
|
||||
{
|
||||
internal class DemoBackgroundService : BackgroundService
|
||||
private int count = 0;
|
||||
|
||||
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
public DemoBackgroundService()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
|
||||
while (!stoppingToken.IsCancellationRequested)
|
||||
{
|
||||
await Task.Delay(1000);
|
||||
count += 1;
|
||||
var msg = new MyMessage(35) { Count = count };
|
||||
WeakReferenceMessenger.Default.Send<MyMessage>(msg);
|
||||
Console.WriteLine("Hello");
|
||||
}
|
||||
}
|
||||
// while (!stoppingToken.IsCancellationRequested)
|
||||
// {
|
||||
// await Task.Delay(1000);
|
||||
// count += 1;
|
||||
// var msg = new MyMessage(35) { Count = count };
|
||||
// WeakReferenceMessenger.Default.Send<MyMessage>(msg);
|
||||
// Console.WriteLine("Hello");
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user