Fixes issue where multiple instances of ApplicaitonLifecycle are created.
This commit is contained in:
parent
5a4a5795b2
commit
ab07ac0389
|
@ -4,6 +4,7 @@ namespace KubernetesWorkflow
|
||||||
{
|
{
|
||||||
public class ApplicationLifecycle
|
public class ApplicationLifecycle
|
||||||
{
|
{
|
||||||
|
private static object instanceLock = new object();
|
||||||
private static ApplicationLifecycle? instance;
|
private static ApplicationLifecycle? instance;
|
||||||
private readonly NumberSource servicePortNumberSource = new NumberSource(30001);
|
private readonly NumberSource servicePortNumberSource = new NumberSource(30001);
|
||||||
private readonly NumberSource namespaceNumberSource = new NumberSource(0);
|
private readonly NumberSource namespaceNumberSource = new NumberSource(0);
|
||||||
|
@ -18,8 +19,11 @@ namespace KubernetesWorkflow
|
||||||
// and persists for the entire application lifecycle.
|
// and persists for the entire application lifecycle.
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (instance == null) instance = new ApplicationLifecycle();
|
lock (instanceLock)
|
||||||
return instance;
|
{
|
||||||
|
if (instance == null) instance = new ApplicationLifecycle();
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue