InstanceStartAttribute class
Marks the method that runs in each instance before its first request, in an application written without ASP.NET.
[AttributeUsage(AttributeTargets.Method)]
public sealed class InstanceStartAttribute : Attribute
Public Members
| name | description |
|---|---|
| InstanceStartAttribute() | The default constructor. |
Remarks
Every instance starts as a copy of the same template, so anything created before the template was saved is identical in all of them. Use this method for state that must differ between instances, such as a random identifier or a random generator you seed yourself.
The method is static, returns Task and takes no parameters. It can have any name, and an application has at most one. An exception fails the request the instance was started for.
An application with a Program.cs subscribes to Starting instead; there the attribute is a build error. Instance lists what Isoplane already reseeds for you, and The application lifecycle explains templates and instances in full.
Examples
private static Guid instance;
[InstanceStart]
public static Task StartAsync()
{
instance = Guid.NewGuid();
return Task.CompletedTask;
}
See Also
- namespace Isoplane