开发者

Is ASP.NET HttpPostedFile.SaveAs a blocking call?

开发者 https://www.devze.com 2023-02-14 07:00 出处:网络
I was wondering whether HttpPostedFile.SaveAs function in ASP.NET C# i开发者_运维问答s a blocking call.Yes (snippet from reflector):

I was wondering whether HttpPostedFile.SaveAs function in ASP.NET C# i开发者_运维问答s a blocking call.


Yes (snippet from reflector):

FileStream s = new FileStream(filename, FileMode.Create);
try
{
    this._stream.WriteTo(s);
    s.Flush();
}
finally
{
    s.Close();
}

It does not use BeginWrite and EndWrite so it is blocking.


UPDATE

If you are wondering what _stream.WriteTo(s); does:

internal void WriteTo(Stream s)
{
    if ((this._data != null) && (this._length > 0))
    {
        this._data.WriteBytes(this._offset, this._length, s);
    }
}

which is again blocking.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号