gpt4 book ai didi

c# - 如何每天重置应用程序变量

转载 作者:行者123 更新时间:2023-11-30 15:00:39 25 4
gpt4 key购买 nike

我正在编写一个程序来记录服务调用和完成的处理。我们有许多打开和关闭调用的用户,我想始终显示今天打开的调用总数和今天关闭的调用总数以及它们之间的差异。我想用一个应用程序变量来做。我必须每天将这些变量重置为 0。我会在哪里做那件事?我想在 Global.asax 中,但在什么情况下可以做到这一点?该应用程序一直在运行,所以我认为 Application_Start 不合适。那么在哪里?谢谢。

最佳答案

您可以配置 Periodic Restart Settings for Application Pool Recycling在 IIS 中:

The element contains configuration settings that allow you to control when an application pool is recycled. You can specify that Internet Information Services (IIS) 7 recycle the application pool after a time interval (in minutes) or at a specific time each day. You can also configure IIS to base the recycle on the amount of virtual memory or physical memory that the worker process in the application pool is using or configure IIS to recycle the application pool after the worker process has processed a specific number of requests.

但这有一个副作用,即在池重新启动期间使应用程序脱机,因此如果您当时有任何用户连接,它将失去其 session 。这可以通过在没有用户连接时(例如黎明时分)重新启动应用程序来最小化。

以下配置片段将应用程序池设置为每天凌晨 3:00 回收:

<add name="Example">
<recycling logEventOnRecycle="Schedule">
<periodicRestart>
<schedule>
<clear />
<add value="03:00:00" />
</schedule>
</periodicRestart>
</recycling>
<processModel identityType="NetworkService" shutdownTimeLimit="00:00:30" startupTimeLimit="00:00:30" />
</add>

关于c# - 如何每天重置应用程序变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15246998/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com