现在我清空 REDIS 的AMS队列 ,让程序无限循环下去,程序使用的内存 一直在增加,问题出在?该如何解决?
await Task.Run(async () =>
{
while (isRun)
{
try
{
string workID = await _redisStorage.ReadAmsOrderAsync();
if (workID != null)
{
}
}
catch
{
}
}
});
///调用
public async Task<string> ReadAmsOrderAsync()
{
string order;
try
{
var csredis = new CSRedis.CSRedisClient(ConnectionString);
order = await csredis.LPopAsync("AM队列");
csredis.Dispose();
}
catch (Exception)
{
order = null;
}
return order;
}
你的while (isRun)是个死循环,变量永远不变,那你在不断调用task的时候,就是在无限增加线程队列啊
线程队列永远处理不完,只增加不减少