internal WaitHandle CloseFileStreams(TorrentManager manager) { ManualResetEvent handle = new ManualResetEvent(false); IOLoop.Queue(delegate { // Process all pending reads/writes then close any open streams try { LoopTask(); if (manager.HasMetadata) { writer.Close(manager.Torrent.Files); } } catch (Exception ex) { Logger.Log(null, "Close file streams error: {0}", ex.Message); SetError(manager, Reason.WriteFailure, ex); } finally { handle.Set(); } }); return(handle); }
internal WaitHandle CloseFileStreams(TorrentManager manager) { var handle = new ManualResetEvent(false); IOLoop.Queue(delegate { // Process all pending reads/writes then close any open streams try { _loopTask(); _writer.Close(manager.Torrent.Files); } catch (Exception ex) { SetError(manager, Reason.WriteFailure, ex); } finally { handle.Set(); } }); return(handle); }