0

I am trying to initialize a singleton class in my azure web role. I tried initializing it in Role.OnStart, but OnStart is called as part of WallSHost.exe process and the requests coming to the role go to w3wp.exe process, where the singleton class is not initialized yet. So it gets initialized when the first request comes to the role. But I am in a situation where the singleton object should be initialized before the first request comes to the role. Application_Start runs as part of w3wp.exe I guess, but Application_start runs only when first request comes to the role. So is there anyway to initialize the singleton object in w3wp.exe before first request comes to the role.

Sai Sunder
  • 1,001
  • 1
  • 11
  • 16
  • as per msdn definition "The OnStart method is called when your role instance is brought online by Azure. While the OnStart code is executing, the role instance is marked as Busy and no external traffic will be directed to it by the load balancer. You can override this method to perform initialization work, such as implementing event handlers ". So you should be able to get your custom code done in OnStart() method – Aravind Nov 11 '16 at 07:14
  • Yes right, I can override onstart, but that executes as part of WallSHost.exe process. I want it part of w3wp.exe process – Sai Sunder Nov 11 '16 at 18:36

0 Answers0