3 ms·
Use F# instead let async_copy (in:Stream) (out:Stream) = asnyc { let buf = Array.create 8192 let rec copy = async { return! match i
by fleitz 16y ago
Use F# instead
let async_copy (in:Stream) (out:Stream) = asnyc {
let buf = Array.create 8192
let rec copy = async {
return! match in.ReadAsync(0,buf.Length,buf) with
| 0 -> ()
| x -> do! out.WriteAsnyc(0,x,buf);
return! copy; }
return! copy; }
There's an async copy routine, not much more overhead than a sync copy.
let sync_copy (in:Stream) (out:Stream) =
let buf = Array.create 8192
let rec copy =
match in.Read(0,buf.Length,buf) with
| 0 -> ()
| x -> out.Write(0,x,buf);
copy
copy
- deleted 16y ago[deleted]
- icey 16y agoSlight typo in the first line of your code; asnyc should be async. Line 6, WriteAsnyc should be WriteAsync The intentions were very clear, just posting this in case someone tries to copy & paste it.