Host Lifecycle
The host opens channels, runs background services, and releases resources in the reverse order during shutdown.
Order
ZeusHost.Create: register channels, devices, and services. Ports are not opened yet.StartAsync: open channels in registration order. If one fails, it is logged and other channels continue.- Runtime: access objects through
Channels,Devices, andPoints; the acquisition loop polls on its interval. StopAsyncorDisposeAsync: stop acquisition and close channels.
await using var app = ZeusHost.Create(builder =>
{
builder.AddVirtualChannel("meter");
});
await app.StartAsync();
// ... application work ...
await app.StopAsync();
Notes
builder.Servicesis a standardIServiceCollection; register your own services there.app.Servicesresolves services after the host is built.StopAsyncpauses acquisition and reconnects, then closes channels.- Calling
StartAsyncagain afterStopAsyncreopens channels. DisposeAsyncreleases process resources; after disposal, create a new host.app.IsRunningreflects whether the user started Zeus, not whether the underlying Generic Host exists.
Common Issues
- Channel becomes
Faultedafter startup: default reconnects will retry, or you can callOpenAsyncmanually. - Serial port remains busy after the process exits: make sure the host was disposed;
AttachZeushandles this for desktop windows.