8 internal class _SslStream
10 private class SplitWriteAsyncProtocolRequest : AsyncProtocolRequest
12 internal SplitWritesState SplitWritesState;
14 internal SplitWriteAsyncProtocolRequest(LazyAsyncResult userAsyncResult)
15 : base(userAsyncResult)
19 internal void SetNextRequest(SplitWritesState splitWritesState, AsyncProtocolCallback callback)
21 SplitWritesState = splitWritesState;
22 SetNextRequest(
null, 0, 0, callback);
28 private static AsyncCallback _MulitpleWriteCallback = MulitpleWriteCallback;
30 private static AsyncProtocolCallback _ResumeAsyncWriteCallback = ResumeAsyncWriteCallback;
32 private static AsyncProtocolCallback _ResumeAsyncReadCallback = ResumeAsyncReadCallback;
34 private static AsyncProtocolCallback _ReadHeaderCallback = ReadHeaderCallback;
36 private static AsyncProtocolCallback _ReadFrameCallback = ReadFrameCallback;
38 private const int PinnableReadBufferSize = 16416;
40 private static PinnableBufferCache s_PinnableReadBufferCache =
new PinnableBufferCache(
"System.Net.SslStream", 16416);
42 private const int PinnableWriteBufferSize = 5120;
44 private static PinnableBufferCache s_PinnableWriteBufferCache =
new PinnableBufferCache(
"System.Net.SslStream", 5120);
46 private SslState _SslState;
48 private int _NestedWrite;
50 private int _NestedRead;
52 private byte[] _InternalBuffer;
54 private bool _InternalBufferFromPinnableCache;
56 private byte[] _PinnableOutputBuffer;
58 private byte[] _PinnableOutputBufferInUse;
60 private int _InternalOffset;
62 private int _InternalBufferCount;
64 private FixedSizeReader _Reader;
66 internal bool DataAvailable => InternalBufferCount != 0;
68 private byte[] InternalBuffer => _InternalBuffer;
70 private int InternalOffset => _InternalOffset;
72 private int InternalBufferCount => _InternalBufferCount;
74 internal _SslStream(SslState sslState)
76 if (PinnableBufferCacheEventSource.Log.IsEnabled())
78 PinnableBufferCacheEventSource.Log.DebugMessage1(
"CTOR: In System.Net._SslStream.SslStream", GetHashCode());
81 _Reader =
new FixedSizeReader(_SslState.InnerStream);
84 private void FreeReadBuffer()
86 if (_InternalBufferFromPinnableCache)
88 s_PinnableReadBufferCache.FreeBuffer(_InternalBuffer);
89 _InternalBufferFromPinnableCache =
false;
91 _InternalBuffer =
null;
96 if (_InternalBufferFromPinnableCache)
98 if (PinnableBufferCacheEventSource.Log.IsEnabled())
100 PinnableBufferCacheEventSource.Log.DebugMessage2(
"DTOR: In System.Net._SslStream.~SslStream Freeing Read Buffer", GetHashCode(), PinnableBufferCacheEventSource.AddressOfByteArray(_InternalBuffer));
104 if (_PinnableOutputBuffer !=
null)
106 if (PinnableBufferCacheEventSource.Log.IsEnabled())
108 PinnableBufferCacheEventSource.Log.DebugMessage2(
"DTOR: In System.Net._SslStream.~SslStream Freeing Write Buffer", GetHashCode(), PinnableBufferCacheEventSource.AddressOfByteArray(_PinnableOutputBuffer));
110 s_PinnableWriteBufferCache.FreeBuffer(_PinnableOutputBuffer);
114 internal int Read(
byte[] buffer,
int offset,
int count)
116 return ProcessRead(buffer, offset, count,
null);
119 internal void Write(
byte[] buffer,
int offset,
int count)
121 ProcessWrite(buffer, offset, count,
null);
124 internal void Write(BufferOffsetSize[] buffers)
126 ProcessWrite(buffers,
null);
131 BufferAsyncResult bufferAsyncResult =
new BufferAsyncResult(
this, buffer, offset, count, asyncState, asyncCallback);
132 AsyncProtocolRequest asyncRequest =
new AsyncProtocolRequest(bufferAsyncResult);
133 ProcessRead(buffer, offset, count, asyncRequest);
134 return bufferAsyncResult;
139 if (asyncResult ==
null)
143 BufferAsyncResult bufferAsyncResult = asyncResult as BufferAsyncResult;
144 if (bufferAsyncResult ==
null)
146 throw new ArgumentException(SR.GetString(
"net_io_async_result", asyncResult.GetType().FullName),
"asyncResult");
152 bufferAsyncResult.InternalWaitForCompletion();
153 if (bufferAsyncResult.Result is
Exception)
157 throw (
Exception)bufferAsyncResult.Result;
161 return (
int)bufferAsyncResult.Result;
166 LazyAsyncResult lazyAsyncResult =
new LazyAsyncResult(
this, asyncState, asyncCallback);
167 AsyncProtocolRequest asyncRequest =
new AsyncProtocolRequest(lazyAsyncResult);
168 ProcessWrite(buffer, offset, count, asyncRequest);
169 return lazyAsyncResult;
174 LazyAsyncResult lazyAsyncResult =
new LazyAsyncResult(
this, asyncState, asyncCallback);
175 SplitWriteAsyncProtocolRequest asyncRequest =
new SplitWriteAsyncProtocolRequest(lazyAsyncResult);
176 ProcessWrite(buffers, asyncRequest);
177 return lazyAsyncResult;
182 if (asyncResult ==
null)
186 LazyAsyncResult lazyAsyncResult = asyncResult as LazyAsyncResult;
187 if (lazyAsyncResult ==
null)
189 throw new ArgumentException(SR.GetString(
"net_io_async_result", asyncResult.GetType().FullName),
"asyncResult");
195 lazyAsyncResult.InternalWaitForCompletion();
206 private void DecrementInternalBufferCount(
int decrCount)
208 _InternalOffset += decrCount;
209 _InternalBufferCount -= decrCount;
212 private void EnsureInternalBufferSize(
int curOffset,
int addSize)
214 if (_InternalBuffer ==
null || _InternalBuffer.Length < addSize + curOffset)
216 bool internalBufferFromPinnableCache = _InternalBufferFromPinnableCache;
217 byte[] internalBuffer = _InternalBuffer;
218 int num = addSize + curOffset;
221 if (PinnableBufferCacheEventSource.Log.IsEnabled())
223 PinnableBufferCacheEventSource.Log.DebugMessage2(
"In System.Net._SslStream.EnsureInternalBufferSize IS pinnable", GetHashCode(), num);
225 _InternalBufferFromPinnableCache =
true;
226 _InternalBuffer = s_PinnableReadBufferCache.AllocateBuffer();
230 if (PinnableBufferCacheEventSource.Log.IsEnabled())
232 PinnableBufferCacheEventSource.Log.DebugMessage2(
"In System.Net._SslStream.EnsureInternalBufferSize NOT pinnable", GetHashCode(), num);
234 _InternalBufferFromPinnableCache =
false;
235 _InternalBuffer =
new byte[num];
237 if (internalBuffer !=
null && curOffset != 0)
241 if (internalBufferFromPinnableCache)
243 s_PinnableReadBufferCache.FreeBuffer(internalBuffer);
246 _InternalOffset = curOffset;
247 _InternalBufferCount = curOffset + addSize;
250 private void ValidateParameters(
byte[] buffer,
int offset,
int count)
264 if (count > buffer.Length - offset)
270 private void ProcessWrite(BufferOffsetSize[] buffers, SplitWriteAsyncProtocolRequest asyncRequest)
272 _SslState.CheckThrow(authSuccessCheck:
true, shutdownCheck:
true);
273 foreach (BufferOffsetSize bufferOffsetSize
in buffers)
275 ValidateParameters(bufferOffsetSize.Buffer, bufferOffsetSize.Offset, bufferOffsetSize.Size);
279 throw new NotSupportedException(SR.GetString(
"net_io_invalidnestedcall", (asyncRequest !=
null) ?
"BeginWrite" :
"Write",
"write"));
284 SplitWritesState splitWritesState =
new SplitWritesState(buffers);
285 asyncRequest?.SetNextRequest(splitWritesState, _ResumeAsyncWriteCallback);
286 StartWriting(splitWritesState, asyncRequest);
290 _SslState.FinishWrite();
296 throw new IOException(SR.GetString(
"net_io_write"), ex);
300 if ((asyncRequest ==
null) | flag)
307 private void ProcessWrite(
byte[] buffer,
int offset,
int count, AsyncProtocolRequest asyncRequest)
309 if (_SslState.LastPayload !=
null)
311 BufferOffsetSize[] buffers =
new BufferOffsetSize[1]
313 new BufferOffsetSize(buffer, offset, count, copyBuffer:
false)
315 if (asyncRequest !=
null)
317 ProcessWrite(buffers,
new SplitWriteAsyncProtocolRequest(asyncRequest.UserAsyncResult));
321 ProcessWrite(buffers,
null);
325 ValidateParameters(buffer, offset, count);
326 _SslState.CheckThrow(authSuccessCheck:
true, shutdownCheck:
true);
329 throw new NotSupportedException(SR.GetString(
"net_io_invalidnestedcall", (asyncRequest !=
null) ?
"BeginWrite" :
"Write",
"write"));
334 StartWriting(buffer, offset, count, asyncRequest);
338 _SslState.FinishWrite();
344 throw new IOException(SR.GetString(
"net_io_write"), ex);
348 if ((asyncRequest ==
null) | flag)
355 private void StartWriting(SplitWritesState splitWrite, SplitWriteAsyncProtocolRequest asyncRequest)
357 while (!splitWrite.IsDone)
359 if (_SslState.CheckEnqueueWrite(asyncRequest))
363 byte[] lastHandshakePayload =
null;
364 if (_SslState.LastPayload !=
null)
366 lastHandshakePayload = _SslState.LastPayload;
367 _SslState.LastPayloadConsumed();
369 BufferOffsetSize[] nextBuffers = splitWrite.GetNextBuffers();
370 nextBuffers = EncryptBuffers(nextBuffers, lastHandshakePayload);
371 if (asyncRequest !=
null)
373 IAsyncResult asyncResult = ((
NetworkStream)_SslState.InnerStream).BeginMultipleWrite(nextBuffers, _MulitpleWriteCallback, asyncRequest);
378 ((
NetworkStream)_SslState.InnerStream).EndMultipleWrite(asyncResult);
382 ((
NetworkStream)_SslState.InnerStream).MultipleWrite(nextBuffers);
384 _SslState.FinishWrite();
386 asyncRequest?.CompleteUser();
389 private BufferOffsetSize[] EncryptBuffers(BufferOffsetSize[] buffers,
byte[] lastHandshakePayload)
392 SecurityStatus securityStatus = SecurityStatus.OK;
393 BufferOffsetSize[] array = buffers;
394 foreach (BufferOffsetSize bufferOffsetSize
in array)
396 int num =
Math.
Min(bufferOffsetSize.Size, _SslState.MaxDataSize);
397 byte[] outBuffer =
null;
398 securityStatus = _SslState.EncryptData(bufferOffsetSize.Buffer, bufferOffsetSize.Offset, num, ref outBuffer, out
int outSize);
399 if (securityStatus != 0)
403 if (num != bufferOffsetSize.Size || list !=
null)
408 if (lastHandshakePayload !=
null)
410 list.Add(
new BufferOffsetSize(lastHandshakePayload, copyBuffer:
false));
412 BufferOffsetSize[] array2 = buffers;
413 foreach (BufferOffsetSize bufferOffsetSize2
in array2)
415 if (bufferOffsetSize2 == bufferOffsetSize)
419 list.Add(bufferOffsetSize2);
422 list.Add(
new BufferOffsetSize(outBuffer, 0, outSize, copyBuffer:
false));
423 while ((bufferOffsetSize.Size -= num) != 0)
425 bufferOffsetSize.Offset += num;
426 num =
Math.
Min(bufferOffsetSize.Size, _SslState.MaxDataSize);
428 securityStatus = _SslState.EncryptData(bufferOffsetSize.Buffer, bufferOffsetSize.Offset, num, ref outBuffer, out outSize);
429 if (securityStatus != 0)
433 list.Add(
new BufferOffsetSize(outBuffer, 0, outSize, copyBuffer:
false));
438 bufferOffsetSize.Buffer = outBuffer;
439 bufferOffsetSize.Offset = 0;
440 bufferOffsetSize.Size = outSize;
442 if (securityStatus != 0)
447 if (securityStatus != 0)
449 ProtocolToken protocolToken =
new ProtocolToken(
null, securityStatus);
450 throw new IOException(SR.GetString(
"net_io_encrypt"), protocolToken.GetException());
454 buffers = list.ToArray();
456 else if (lastHandshakePayload !=
null)
458 BufferOffsetSize[] array3 =
new BufferOffsetSize[buffers.Length + 1];
459 Array.
Copy(buffers, 0, array3, 1, buffers.Length);
460 array3[0] =
new BufferOffsetSize(lastHandshakePayload, copyBuffer:
false);
466 private void StartWriting(
byte[] buffer,
int offset,
int count, AsyncProtocolRequest asyncRequest)
468 asyncRequest?.SetNextRequest(buffer, offset, count, _ResumeAsyncWriteCallback);
471 byte[] outBuffer =
null;
472 if (_PinnableOutputBufferInUse ==
null)
474 if (_PinnableOutputBuffer ==
null)
476 _PinnableOutputBuffer = s_PinnableWriteBufferCache.AllocateBuffer();
478 _PinnableOutputBufferInUse = buffer;
479 outBuffer = _PinnableOutputBuffer;
480 if (PinnableBufferCacheEventSource.Log.IsEnabled())
482 PinnableBufferCacheEventSource.Log.DebugMessage3(
"In System.Net._SslStream.StartWriting Trying Pinnable", GetHashCode(), count, PinnableBufferCacheEventSource.AddressOfByteArray(outBuffer));
485 else if (PinnableBufferCacheEventSource.Log.IsEnabled())
487 PinnableBufferCacheEventSource.Log.DebugMessage2(
"In System.Net._SslStream.StartWriting BufferInUse", GetHashCode(), count);
491 if (_SslState.CheckEnqueueWrite(asyncRequest))
495 int num =
Math.
Min(count, _SslState.MaxDataSize);
497 SecurityStatus securityStatus = _SslState.EncryptData(buffer, offset, num, ref outBuffer, out outSize);
498 if (securityStatus != 0)
500 ProtocolToken protocolToken =
new ProtocolToken(
null, securityStatus);
501 throw new IOException(SR.GetString(
"net_io_encrypt"), protocolToken.GetException());
503 if (PinnableBufferCacheEventSource.Log.IsEnabled())
505 PinnableBufferCacheEventSource.Log.DebugMessage3(
"In System.Net._SslStream.StartWriting Got Encrypted Buffer", GetHashCode(), outSize, PinnableBufferCacheEventSource.AddressOfByteArray(outBuffer));
507 if (asyncRequest !=
null)
509 asyncRequest.SetNextRequest(buffer, offset + num, count - num, _ResumeAsyncWriteCallback);
510 IAsyncResult asyncResult = _SslState.InnerStream.BeginWrite(outBuffer, 0, outSize, _WriteCallback, asyncRequest);
515 _SslState.InnerStream.EndWrite(asyncResult);
519 _SslState.InnerStream.Write(outBuffer, 0, outSize);
523 _SslState.FinishWrite();
527 asyncRequest?.CompleteUser();
528 if (buffer == _PinnableOutputBufferInUse)
530 _PinnableOutputBufferInUse =
null;
531 if (PinnableBufferCacheEventSource.Log.IsEnabled())
533 PinnableBufferCacheEventSource.Log.DebugMessage1(
"In System.Net._SslStream.StartWriting Freeing buffer.", GetHashCode());
538 private int ProcessRead(
byte[] buffer,
int offset,
int count, AsyncProtocolRequest asyncRequest)
540 ValidateParameters(buffer, offset, count);
543 throw new NotSupportedException(SR.GetString(
"net_io_invalidnestedcall", (asyncRequest !=
null) ?
"BeginRead" :
"Read",
"read"));
548 if (InternalBufferCount != 0)
550 int num = (InternalBufferCount > count) ? count : InternalBufferCount;
554 DecrementInternalBufferCount(num);
556 asyncRequest?.CompleteUser(num);
559 return StartReading(buffer, offset, count, asyncRequest);
563 _SslState.FinishRead(
null);
569 throw new IOException(SR.GetString(
"net_io_read"), ex);
573 if ((asyncRequest ==
null) | flag)
580 private int StartReading(
byte[] buffer,
int offset,
int count, AsyncProtocolRequest asyncRequest)
585 asyncRequest?.SetNextRequest(buffer, offset, count, _ResumeAsyncReadCallback);
586 int num2 = _SslState.CheckEnqueueRead(buffer, offset, count, asyncRequest);
594 asyncRequest?.CompleteUser(num2);
597 while ((num = StartFrameHeader(buffer, offset, count, asyncRequest)) == -1);
601 private int StartFrameHeader(
byte[] buffer,
int offset,
int count, AsyncProtocolRequest asyncRequest)
604 EnsureInternalBufferSize(0, 5);
605 if (asyncRequest !=
null)
607 asyncRequest.SetNextRequest(InternalBuffer, 0, 5, _ReadHeaderCallback);
608 _Reader.AsyncReadPacket(asyncRequest);
609 if (!asyncRequest.MustCompleteSynchronously)
613 num = asyncRequest.Result;
617 num = _Reader.ReadPacket(InternalBuffer, 0, 5);
619 return StartFrameBody(num, buffer, offset, count, asyncRequest);
622 private int StartFrameBody(
int readBytes,
byte[] buffer,
int offset,
int count, AsyncProtocolRequest asyncRequest)
626 DecrementInternalBufferCount(InternalBufferCount);
627 asyncRequest?.CompleteUser(0);
630 readBytes = _SslState.GetRemainingFrameSize(InternalBuffer, readBytes);
633 throw new IOException(SR.GetString(
"net_frame_read_size"));
635 EnsureInternalBufferSize(5, readBytes);
636 if (asyncRequest !=
null)
638 asyncRequest.SetNextRequest(InternalBuffer, 5, readBytes, _ReadFrameCallback);
639 _Reader.AsyncReadPacket(asyncRequest);
640 if (!asyncRequest.MustCompleteSynchronously)
644 readBytes = asyncRequest.Result;
648 readBytes = _Reader.ReadPacket(InternalBuffer, 5, readBytes);
650 return ProcessFrameBody(readBytes, buffer, offset, count, asyncRequest);
653 private int ProcessFrameBody(
int readBytes,
byte[] buffer,
int offset,
int count, AsyncProtocolRequest asyncRequest)
661 SecurityStatus securityStatus = _SslState.DecryptData(InternalBuffer, ref offset2, ref readBytes);
662 if (securityStatus != 0)
667 array =
new byte[readBytes];
670 DecrementInternalBufferCount(InternalBufferCount);
671 return ProcessReadErrorCode(securityStatus, buffer, offset, count, asyncRequest, array);
673 if (readBytes == 0 && count != 0)
675 DecrementInternalBufferCount(InternalBufferCount);
678 EnsureInternalBufferSize(0, offset2 + readBytes);
679 DecrementInternalBufferCount(offset2);
680 if (readBytes > count)
684 Buffer.
BlockCopy(InternalBuffer, InternalOffset, buffer, offset, readBytes);
685 DecrementInternalBufferCount(readBytes);
686 _SslState.FinishRead(
null);
687 asyncRequest?.CompleteUser(readBytes);
691 private int ProcessReadErrorCode(SecurityStatus errorCode,
byte[] buffer,
int offset,
int count, AsyncProtocolRequest asyncRequest,
byte[] extraBuffer)
693 ProtocolToken protocolToken =
new ProtocolToken(
null, errorCode);
694 if (protocolToken.Renegotiate)
696 _SslState.ReplyOnReAuthentication(extraBuffer);
699 if (protocolToken.CloseConnection)
701 _SslState.FinishRead(
null);
702 asyncRequest?.CompleteUser(0);
705 throw new IOException(SR.GetString(
"net_io_decrypt"), protocolToken.GetException());
708 private static void WriteCallback(
IAsyncResult transportResult)
712 AsyncProtocolRequest asyncProtocolRequest = (AsyncProtocolRequest)transportResult.
AsyncState;
713 _SslStream sslStream = (_SslStream)asyncProtocolRequest.AsyncObject;
716 sslStream._SslState.InnerStream.EndWrite(transportResult);
717 sslStream._SslState.FinishWrite();
718 if (asyncProtocolRequest.Count == 0)
720 asyncProtocolRequest.Count = -1;
722 sslStream.StartWriting(asyncProtocolRequest.Buffer, asyncProtocolRequest.Offset, asyncProtocolRequest.Count, asyncProtocolRequest);
726 if (asyncProtocolRequest.IsUserCompleted)
730 sslStream._SslState.FinishWrite();
731 asyncProtocolRequest.CompleteWithError(e);
736 private static void MulitpleWriteCallback(
IAsyncResult transportResult)
740 SplitWriteAsyncProtocolRequest splitWriteAsyncProtocolRequest = (SplitWriteAsyncProtocolRequest)transportResult.
AsyncState;
741 _SslStream sslStream = (_SslStream)splitWriteAsyncProtocolRequest.AsyncObject;
744 ((
NetworkStream)sslStream._SslState.InnerStream).EndMultipleWrite(transportResult);
745 sslStream._SslState.FinishWrite();
746 sslStream.StartWriting(splitWriteAsyncProtocolRequest.SplitWritesState, splitWriteAsyncProtocolRequest);
750 if (splitWriteAsyncProtocolRequest.IsUserCompleted)
754 sslStream._SslState.FinishWrite();
755 splitWriteAsyncProtocolRequest.CompleteWithError(e);
760 private static void ResumeAsyncReadCallback(AsyncProtocolRequest request)
764 ((_SslStream)request.AsyncObject).StartReading(request.Buffer, request.Offset, request.Count, request);
768 if (request.IsUserCompleted)
772 ((_SslStream)request.AsyncObject)._SslState.FinishRead(
null);
773 request.CompleteWithError(e);
777 private static void ResumeAsyncWriteCallback(AsyncProtocolRequest asyncRequest)
781 SplitWriteAsyncProtocolRequest splitWriteAsyncProtocolRequest = asyncRequest as SplitWriteAsyncProtocolRequest;
782 if (splitWriteAsyncProtocolRequest !=
null)
784 ((_SslStream)asyncRequest.AsyncObject).StartWriting(splitWriteAsyncProtocolRequest.SplitWritesState, splitWriteAsyncProtocolRequest);
788 ((_SslStream)asyncRequest.AsyncObject).StartWriting(asyncRequest.Buffer, asyncRequest.Offset, asyncRequest.Count, asyncRequest);
793 if (asyncRequest.IsUserCompleted)
797 ((_SslStream)asyncRequest.AsyncObject)._SslState.FinishWrite();
798 asyncRequest.CompleteWithError(e);
802 private static void ReadHeaderCallback(AsyncProtocolRequest asyncRequest)
806 _SslStream sslStream = (_SslStream)asyncRequest.AsyncObject;
807 BufferAsyncResult bufferAsyncResult = (BufferAsyncResult)asyncRequest.UserAsyncResult;
808 if (-1 == sslStream.StartFrameBody(asyncRequest.Result, bufferAsyncResult.Buffer, bufferAsyncResult.Offset, bufferAsyncResult.Count, asyncRequest))
810 sslStream.StartReading(bufferAsyncResult.Buffer, bufferAsyncResult.Offset, bufferAsyncResult.Count, asyncRequest);
815 if (asyncRequest.IsUserCompleted)
819 asyncRequest.CompleteWithError(e);
823 private static void ReadFrameCallback(AsyncProtocolRequest asyncRequest)
827 _SslStream sslStream = (_SslStream)asyncRequest.AsyncObject;
828 BufferAsyncResult bufferAsyncResult = (BufferAsyncResult)asyncRequest.UserAsyncResult;
829 if (-1 == sslStream.ProcessFrameBody(asyncRequest.Result, bufferAsyncResult.Buffer, bufferAsyncResult.Offset, bufferAsyncResult.Count, asyncRequest))
831 sslStream.StartReading(bufferAsyncResult.Buffer, bufferAsyncResult.Offset, bufferAsyncResult.Count, asyncRequest);
836 if (asyncRequest.IsUserCompleted)
840 asyncRequest.CompleteWithError(e);
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
static sbyte Min(sbyte val1, sbyte val2)
Returns the smaller of two 8-bit signed integers.
The exception that is thrown when the value of an argument is outside the allowable range of values a...
delegate void AsyncCallback(IAsyncResult ar)
References a method to be called when a corresponding asynchronous operation completes.
object AsyncState
Gets a user-defined object that qualifies or contains information about an asynchronous operation.
static int Exchange(ref int location1, int value)
Sets a 32-bit signed integer to a specified value and returns the original value, as an atomic operat...
Represents the status of an asynchronous operation.
static void BlockCopy(Array src, int srcOffset, Array dst, int dstOffset, int count)
Copies a specified number of bytes from a source array starting at a particular offset to a destinati...
The exception that is thrown when an I/O error occurs.
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
bool CompletedSynchronously
Gets a value that indicates whether the asynchronous operation completed synchronously.
The exception that is thrown when one of the arguments provided to a method is not valid.
static void Copy(Array sourceArray, Array destinationArray, int length)
Copies a range of elements from an T:System.Array starting at the first element and pastes them into ...
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
Represents errors that occur during application execution.To browse the .NET Framework source code fo...
The exception that is thrown when a method call is invalid for the object's current state.
Manipulates arrays of primitive types.
Provides constants and static methods for trigonometric, logarithmic, and other common mathematical f...
The exception that is thrown when an invoked method is not supported, or when there is an attempt to ...
Provides atomic operations for variables that are shared by multiple threads.
Provides the underlying stream of data for network access.