我正在尝试将stream-parameter传递给异步方法,如下所示:
async void MyAsyncMethod(Stream s, int i)
{
await Task.Factory.StartNew(() =>
{
SomeMethodReadingFromStream(s, i); // throws ArgumentException, "Stream was not readable."
});
}
Run Code Online (Sandbox Code Playgroud)
当我使MyAsyncMethod不使用async-await时,一切正常.
有没有办法在异步方法中使用流?