Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ClosableStream.cs
Go to the documentation of this file.
1using System.IO;
3
4namespace System.Net;
5
6internal sealed class ClosableStream : DelegatedStream
7{
8 private readonly EventHandler _onClose;
9
10 private int _closed;
11
12 internal ClosableStream(Stream stream, EventHandler onClose)
13 : base(stream)
14 {
15 _onClose = onClose;
16 }
17
18 public override void Close()
19 {
20 if (Interlocked.Increment(ref _closed) == 1)
21 {
22 _onClose?.Invoke(this, new EventArgs());
23 }
24 }
25}
ClosableStream(Stream stream, EventHandler onClose)
readonly EventHandler _onClose
static int Increment(ref int location)