private static void ApplicationStopping(IApplicationBuilder app, IHostApplicationLifetime lifetime)
 {
     lifetime.ApplicationStopping.Register((context) =>
     {
         IApplicationBuilder builder     = context as IApplicationBuilder;
         ProcessEngineFactory engineFact = builder.ApplicationServices.GetService <ProcessEngineFactory>();
         engineFact.Destroy();
     }, app, true);
 }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="app"></param>
        /// <returns></returns>
        public static IApplicationBuilder UseProcessEngine(this IApplicationBuilder app, IApplicationLifetime lifetime)
        {
            app.ApplicationServices.EnsureProcessEngineInit();

            app.ApplicationServices.GetService <IOptionsMonitor <ProcessEngineOption> >()
            .OnChange((opts, prop) =>
            {
                if (ProcessEngineOption.HasChanged())
                {
                    ProcessEngineFactory.Instance.Destroy();
                    app.ApplicationServices.EnsureProcessEngineInit();
                }
            });

            lifetime.ApplicationStopping.Register((context) =>
            {
                IApplicationBuilder builder     = context as IApplicationBuilder;
                ProcessEngineFactory engineFact = builder.ApplicationServices.GetService <ProcessEngineFactory>();
                engineFact.Destroy();
            }, app, true);
            return(app);
        }