응용 프로그램의 파일 다운로드 속도를 제한하는 코드를 다음과 같이 사용했습니다. 언제나 파일 다운로드에 대한 대역폭 조절
context.Response.Buffer = false;
context.Response.AppendHeader("Content-Disposition",
"attachment;filename=" + arquivo.Nome);
context.Response.AppendHeader("Content-Type",
"application/octet-stream");
context.Response.AppendHeader("Content-Length",
arquivo.Tamanho.ToString());
int offset = 0;
byte[] buffer = new byte[currentRange.OptimalDownloadRate];
while (context.Response.IsClientConnected && offset < arquivo.Tamanho)
{
DateTime start = DateTime.Now;
int readCount = arquivo.GetBytes(buffer, offset, // == .ExecuteReader()
(int)Math.Min(arquivo.Tamanho - offset, buffer.Length));
context.Response.OutputStream.Write(buffer, 0, readCount);
offset += readCount;
CacheManager.Hit(jobId, fileId.ToString(), readCount, buffer.Length, null);
TimeSpan elapsed = DateTime.Now - start;
if (elapsed.TotalMilliseconds < 1000)
{
Thread.Sleep(1000 - (int)elapsed.TotalMilliseconds);
}
}
, 그것은 내 개발, 내부 고객 QA 환경에 잘 작동하지만 프로덕션 환경에서 예외를 던지고 :
사용자에 대해
System.Threading.ThreadAbortException: Thread was being aborted.
at System.Threading.Thread.SleepInternal(Int32 millisecondsTimeout)
at (...).Handlers.DownloadHandler.processDownload(HttpContext context, ...)
새 창 다운로드 대화 상자에 열립니다
The connection with the server was reset
무슨 일이 일어나는지 알고 있니?
답변이 없지만 일반적으로 다음과 같이 보입니다. http://www.google.com/search?q=SleepInternal+threadabortexception – asveikau