November Happy Hour will be moved to Thursday December 5th.

When does the UNinitialize method in an InitializationModule get called in an applications lifecycle?

Vote:
 

The Dev Guide for CMS 12 says this regarding Initializing the CMS (here):

Custom initialization logic can preferably be done through standard ASP.NET 
Core components like for example IStartupFilter or  IHostedService. The
IInitializable system (described below) within CMS that was built for
ASP.NET - where there was no central Startup class - is also available in
ASP.NET Core application and can be used also.

Has anyone successfully converted an InitializationModule with events into standard .NET Core components? I found an add-on where the Initialize() method is called during Startup/Configure() but it doesn't use an Uninitialize() method. IHostedService only has StartAsync and StopAsync which might* be comparable to Initialize() and Uninitialize(). (*I'm still learning about IHostedService.) 

I have a couple of questions then:

  1. Where in the application's startup pipeline is Optimizely's InitializableModule called to set and call Initialize() and then Uninitialize()?
  2. Is IHostedService.StartAsync/StopAsync the same as Initialize() and Uninitialize()? If so, I can follow the instructions in the link behind IHostedService above.
  3. Also, if it's the same, do I call it in Startup/ConfigureServices() or Startup/Configure() in Startup.cs or somewhere else?

Questions 1 & 3 could be answered if there's a diagram of the startup pipeline for CMS 12.

Thank you!!

#312621
Edited, Nov 15, 2023 23:06
Vote:
 

Hate to answer my own question, but I figured out today that I was searching for Uninitialize when I should have been searching for IHostedServices.

There are a couple of examples others have posted in the forums, like Henrik's example here.
https://world.optimizely.com/forum/developer-forum/cms-12/thread-container/2022/3/contentevents-in-cms-12/#275793

And Minesh's example here:
https://world.optimizely.com/forum/developer-forum/cms-12/thread-container/2022/10/making-an-async-http-call-on-publish/#290453

#312681
Nov 16, 2023 23:22
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.