本文介绍了在Web服务中20分钟后计时器停止工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为我的计时器会在一段时间后停止工作,我刚刚确定20分钟后才发现到目前为止导致停止的其他原因.如果收集了垃圾,该如何声明它呢?

I think my timer stops working after some time, I meassured 20min just now and havnt found anything else that causes the stop so far. If its garbage collected, how should I declare it so that it isnt?

[WebMethod, SoapHeader("spAuthenticationHeader")]
public void startStreaming()
{
    if (Globals._streamTimer == null)
        Globals._streamTimer = new System.Threading.Timer(handleStream, null, 0, 30000);
        return Globals._returnValue;
}


public static class Globals
{
    public static System.Threading.Timer _streamTimer = null;
}

推荐答案

看看您的IIS设置-20分钟?

Take a look at your IIS settings - 20 minutes?

Web应用程序不应长时间运行.无论您在做什么,都应该以不同的方式进行.也许是Windows服务,或持久性存储和轮询...

Web applications are not supposed to be long-running. Whatever you are doing, you should do it differently. Perhaps a Windows Service, or persistent storage and polling...

或者,您可以对其进行模糊处理并增加超时值.

Or, you can kludge it and increase the time-out value.

这篇关于在Web服务中20分钟后计时器停止工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 23:18