Pergunta

Eu tenho um manipulador que faz um trabalho duro sob imagens. Parece http://example.com/webservice.ashx?imageparam1=100&ImageParam2=200

Cada solicitação a esse manipulador leva cerca de 2-3 segundos.

Preciso de uma maneira de abortar a geração de imagens se o cliente fechar a conexão (ou seja, fechar a página ou enviar uma solicitação para outra imagem).

Existe uma maneira de fazer isso?

Foi útil?

Solução

You have to watch IsClientConnected property of HttpContext.Response object. When it changes to false, cancel image generation.

I can't provide more ideas as it depends on the way you create image. I can only advice to make separate generation thread that can be aborted from main thread that periodically checks connection. Also generator's resources have to be cleaned up somehow and that can be major issue increasing solution complexity.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top