0
votes

I need to download some tables from the database, and create static list classes with the information. I can do this in owin startup, or RoleEntryPoint onStart.

I tried to preload the lists in RoleEntryPoint onStart, however, these classes doesnt seem to be available in the runtime, instead they got created again.

If I preload them in Owin Startup, everything works as it should.

However, it takes about 10 seconds for me to preload these lists, and while owin startup is executing, the Onstart already had been executed and therefore the web role becomes available for accepting requests. I dont want this though. I dont want the web role to switch to ready state until all of the lists are preloaded.

it seems like any instances that are created in RoleEntryPoint arent available in the webrole runtime itself.

Is there any way to achieve preloading instances in OnStart and having being able to use them in the runtime?

1

1 Answers

0
votes

RoleEntryPoint is the best way to achieve your requirement.

Define static List variables with singleton pattern in the WebRole.cs. Implement async repository or private methods to fill them. You do not have to populate your static lists on app startup. According to the singleton pattern, they will get filled on first request.

I use the same approach in my static repository instance initialization of WCF service startup process. Good luck