C#C
C#6mo ago
VoidPointer

Concurrency Problem With Adding a Service in Startup

I have to startup up 10 old fashioned, controller based web APIs together, using the VS multi-project startup, but it starts them all up simultaneously.

Now in each startup's ConfigureServices, I have one of these:
services.AddCassandraSession();

The code inside this method creates a connection (ISession) to a Cassandra cluster, but it has to make calls to our config API, and when one startup project calls this method before it has finished for another project, it does the config a dirty and e.g. an empty username is passed to the new Cassandra session, causing an exception.

One solution that has occurred to me is to somehow queue the requests to add the session to the API's services, but that would be quite some work. Another is to start the project's sequentially, but I don't see any way to tell VS to do this.
Was this page helpful?