This commit is contained in:
bytewizer 2022-07-10 09:52:18 -07:00
Родитель b321d35df3
Коммит e36b8d0788
4 изменённых файлов: 9 добавлений и 8 удалений

Просмотреть файл

@ -27,6 +27,7 @@ This API mirrors as close as possible the official .NET
```csharp
using nanoFramework.Hosting;
using nanoFramework.DependencyInjection;
namespace Hosting
{
@ -44,9 +45,10 @@ namespace Hosting
Host.CreateDefaultBuilder()
.ConfigureServices(services =>
{
services.AddSingleton(typeof(BackgroundQueue));
services.AddHostedService(typeof(SensorService));
services.AddHostedService(typeof(DisplayService));
services.AddHostedService(typeof(CustomeService));
services.AddHostedService(typeof(CustomService));
});
}
}
@ -92,7 +94,7 @@ public class DisplayService : SchedulerService
When you register an IHostedService the host builder will call the *Start* and *Stop* methods of IHostedService type during application start and stop respectively. You can create multiple implementations of IHostedService and register them at the ConfigureService method into the DI container. All hosted services will be started and stopped along with the application.
```csharp
public class CustomeService : IHostedService
public class CustomService : IHostedService
{
public void Start() { }

Просмотреть файл

@ -57,16 +57,15 @@ namespace nanoFramework.Hosting
/// This method is called when the <see cref="IHostedService"/> starts. The implementation should return a thread that represents
/// the lifetime of the long running operation(s) being performed.
/// </summary>
/// <param name="state">An object containing information to be used by the callback method, or null.</param>
protected abstract void ExecuteAsync(object state);
protected abstract void ExecuteAsync();
/// <inheritdoc />
public virtual void Start()
{
_executeTimer = new Timer(state =>
{
ExecuteAsync(state);
}, _executeTimer, _time, _interval);
ExecuteAsync();
}, null, _time, _interval);
}
/// <inheritdoc />

Просмотреть файл

@ -16,7 +16,7 @@ namespace nanoFramework.Hosting.UnitTests.Fakes
throw new NotImplementedException();
}
protected override void ExecuteAsync(object state)
protected override void ExecuteAsync()
{
throw new NotImplementedException();
}

Просмотреть файл

@ -20,7 +20,7 @@ namespace nanoFramework.Hosting.UnitTests.Fakes
base.Start();
}
protected override void ExecuteAsync(object state)
protected override void ExecuteAsync()
{
IsCompleted = true;
}