Skip to main content

Host Lifecycle

The host opens channels, runs background services, and releases resources in the reverse order during shutdown.

Order

  1. ZeusHost.Create: register channels, devices, and services. Ports are not opened yet.
  2. StartAsync: open channels in registration order. If one fails, it is logged and other channels continue.
  3. Runtime: access objects through Channels, Devices, and Points; the acquisition loop polls on its interval.
  4. StopAsync or DisposeAsync: 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.Services is a standard IServiceCollection; register your own services there.
  • app.Services resolves services after the host is built.
  • StopAsync pauses acquisition and reconnects, then closes channels.
  • Calling StartAsync again after StopAsync reopens channels.
  • DisposeAsync releases process resources; after disposal, create a new host.
  • app.IsRunning reflects whether the user started Zeus, not whether the underlying Generic Host exists.

Common Issues

  • Channel becomes Faulted after startup: default reconnects will retry, or you can call OpenAsync manually.
  • Serial port remains busy after the process exits: make sure the host was disposed; AttachZeus handles this for desktop windows.