4 instantiations of GCHandle
PresentationCore (1)
src\Microsoft.DotNet.Wpf\src\Shared\MS\Internal\CharacterBuffer.cs (1)
428gcHandle = new GCHandle();
System.Private.CoreLib (3)
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\GCHandle.cs (3)
65public static GCHandle Alloc(object? value) => new GCHandle(value, GCHandleType.Normal); 72public static GCHandle Alloc(object? value, GCHandleType type) => new GCHandle(value, type); 161return new GCHandle(value);
369 references to GCHandle
Microsoft.AspNetCore.Server.HttpSys (7)
RequestProcessing\ResponseBody.cs (7)
144Span<GCHandle> pinnedBuffers = default; 190private unsafe void BuildDataChunks(scoped ref UnmanagedBufferAllocator allocator, bool endOfRequest, ArraySegment<byte> data, out Span<HTTP_DATA_CHUNK> dataChunks, out Span<GCHandle> pins) 235pins = allocator.AllocAsSpan<GCHandle>(2); 279out GCHandle handle) 281handle = GCHandle.Alloc(buffer.Array, GCHandleType.Pinned); 299private static void FreeDataBuffers(Span<GCHandle> pinnedBuffers) 301foreach (var pin in pinnedBuffers)
Microsoft.AspNetCore.Server.IIS (15)
Core\IISHttpContext.cs (2)
59private GCHandle _thisHandle = default!; 156_thisHandle = GCHandle.Alloc(this);
Core\IISHttpServer.cs (7)
25private GCHandle _httpServerHandle; 95_httpServerHandle = GCHandle.Alloc(this); 154server = (IISHttpServer?)GCHandle.FromIntPtr(pvRequestContext).Target; 185server = (IISHttpServer?)GCHandle.FromIntPtr(pvRequestContext).Target; 209context = (IISHttpContext?)GCHandle.FromIntPtr(pvManagedHttpContext).Target; 231context = (IISHttpContext?)GCHandle.FromIntPtr(pvManagedHttpContext).Target; 256server = (IISHttpServer?)GCHandle.FromIntPtr(serverContext).Target;
Core\IO\WebSocketsAsyncIOEngine.Read.cs (3)
17var context = (WebSocketReadOperation)GCHandle.FromIntPtr(completionContext).Target!; 29private readonly GCHandle _thisHandle; 36_thisHandle = GCHandle.Alloc(this);
Core\IO\WebSocketsAsyncIOEngine.Write.cs (3)
16var context = (WebSocketWriteOperation)GCHandle.FromIntPtr(completionContext).Target!; 27private readonly GCHandle _thisHandle; 31_thisHandle = GCHandle.Alloc(this);
Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests (1)
CodeGeneration\SyntaxGeneratorTests.cs (1)
1052var gcHandleType = _emptyCompilation.GetTypeByMetadataName(typeof(GCHandle).FullName);
Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities (1)
BlindAggregatorFactory.cs (1)
70GCHandle.FromIntPtr(_gcHandle).Free();
Microsoft.CodeAnalysis.VisualBasic.Semantic.UnitTests (1)
Compilation\CompilationAPITests.vb (1)
2473Dim pinnedPEImage = GCHandle.Alloc(moduleBytes.ToArray(), GCHandleType.Pinned)
Microsoft.CodeAnalysis.VisualBasic.Workspaces.UnitTests (1)
CodeGeneration\SyntaxGeneratorTests.vb (1)
1065Dim gcHandleType = _emptyCompilation.GetTypeByMetadataName(GetType(GCHandle).FullName)
Microsoft.ML.LightGbm (6)
WrappedLightGbmDataset.cs (6)
52GCHandle[] gcValues = new GCHandle[numCol]; 53GCHandle[] gcIndices = new GCHandle[numCol]; 60gcValues[i] = GCHandle.Alloc(sampleValuePerColumn[i], GCHandleType.Pinned); 62gcIndices[i] = GCHandle.Alloc(sampleIndicesPerColumn[i], GCHandleType.Pinned);
Microsoft.ML.Mkl.Components (12)
SymSgdClassificationTrainer.cs (12)
341public GCHandle GcHandle; 346GcHandle = GCHandle.Alloc(Buffer, GCHandleType.Pinned); 487public void GiveArrayOfSize(int size, out GCHandle? outGcHandle, out int outArrayStartIndex) 663public bool GiveNextInstance(out InstanceProperties? prop, out GCHandle? indicesGcHandle, out int indicesStartIndex, 664out GCHandle? valuesGcHandle, out int valuesStartIndex) 736GCHandle stateGCHandle = default; 739stateGCHandle = GCHandle.Alloc(state, GCHandleType.Pinned); 863int numThreads, bool tuneNumLocIter, ref int numLocIter, float tolerance, bool needShuffle, bool shouldInitialize, GCHandle stateGCHandle, ChannelCallBack info) 878while (inputDataManager.GiveNextInstance(out InstanceProperties? prop, out GCHandle? indicesGcHandle, out int indicesStartIndex, out GCHandle? valuesGcHandle, out int valuesStartIndex)) 917public static void MapBackWeightVector(Span<float> weightVector, GCHandle stateGCHandle) 926public static void DeallocateSequentially(GCHandle stateGCHandle)
Microsoft.ML.Vision (4)
ImageClassificationTrainer.cs (4)
991var featureBufferHandle = GCHandle.Alloc(featuresBuffer, GCHandleType.Pinned); 993var labelBufferHandle = GCHandle.Alloc(labelBuffer, GCHandleType.Pinned);
Microsoft.NET.StringTools (2)
WeakStringCache.cs (2)
36public GCHandle WeakHandle; 93WeakHandle = GCHandle.Alloc(str, GCHandleType.Weak);
Microsoft.NET.StringTools.net35 (2)
WeakStringCache.cs (2)
36public GCHandle WeakHandle; 93WeakHandle = GCHandle.Alloc(str, GCHandleType.Weak);
Microsoft.VisualStudio.LanguageServices (5)
Interop\ComAggregate.cs (4)
58var handle = GCHandle.FromIntPtr(comWrapper.GCHandlePtr); 83var handle = GCHandle.FromIntPtr(comWrapper.GCHandlePtr);
Interop\IComWrapperFixed.cs (1)
20/// <returns>An <see cref="IntPtr"/> which can be passed to <see cref="GCHandle.FromIntPtr(IntPtr)"/> to obtain
Microsoft.VisualStudio.LanguageServices.Test.Utilities2 (2)
CodeModel\CodeModelTestHelpers.vb (2)
110Dim handle = GCHandle.Alloc(managedObject, GCHandleType.Normal) 114BlindAggregatorFactory.SetInnerObject(wrapperUnknown, innerUnknown, GCHandle.ToIntPtr(handle))
mscorlib (1)
src\libraries\shims\mscorlib\ref\mscorlib.cs (1)
691[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.InteropServices.GCHandle))]
netstandard (1)
netstandard.cs (1)
1696[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.InteropServices.GCHandle))]
PresentationCore (23)
MS\Internal\FontCache\FontSource.cs (2)
397_memoryHandle = GCHandle.Alloc(bits, GCHandleType.Pinned); 423private GCHandle _memoryHandle;
MS\Internal\Shaping\TypefaceMap.cs (1)
91GCHandle gcHandle;
src\Microsoft.DotNet.Wpf\src\Shared\MS\Internal\CharacterBuffer.cs (10)
39public abstract IntPtr PinAndGetCharacterPointer(int offset, out GCHandle gcHandle); 44public abstract void UnpinCharacterPointer(GCHandle gcHandle); 218public override unsafe IntPtr PinAndGetCharacterPointer(int offset, out GCHandle gcHandle) 220gcHandle = GCHandle.Alloc(_characterArray, GCHandleType.Pinned); 227public override void UnpinCharacterPointer(GCHandle gcHandle) 317public override unsafe IntPtr PinAndGetCharacterPointer(int offset, out GCHandle gcHandle) 319gcHandle = GCHandle.Alloc(_string, GCHandleType.Pinned); 326public override void UnpinCharacterPointer(GCHandle gcHandle) 426public override IntPtr PinAndGetCharacterPointer(int offset, out GCHandle gcHandle) 435public override void UnpinCharacterPointer(GCHandle gcHandle)
System\Windows\Media\EventProxy.cs (5)
31((System.Runtime.InteropServices.GCHandle)(pEPD.m_handle)).Free(); 34internal System.Runtime.InteropServices.GCHandle m_handle; 105System.Runtime.InteropServices.GCHandle handle = (System.Runtime.InteropServices.GCHandle)(epd.m_handle); 138m_handle = System.Runtime.InteropServices.GCHandle.Alloc(epw, System.Runtime.InteropServices.GCHandleType.Normal)
System\Windows\Media\StreamAsIStream.cs (5)
55((System.Runtime.InteropServices.GCHandle)(pSD.m_handle)).Free(); 58internal System.Runtime.InteropServices.GCHandle m_handle; 510System.Runtime.InteropServices.GCHandle handle = (System.Runtime.InteropServices.GCHandle)(sd.m_handle); 657sd.m_handle = System.Runtime.InteropServices.GCHandle.Alloc(sais, System.Runtime.InteropServices.GCHandleType.Normal);
PresentationFramework (12)
MS\Internal\WindowsRuntime\Generated\WinRT\Marshalers.cs (5)
16public static void Dispose(this GCHandle handle) 35public GCHandle _gchandle; 51m._gchandle = GCHandle.Alloc(value, GCHandleType.Pinned); 276public MarshalerArray(Array array) => _gchandle = GCHandle.Alloc(array, GCHandleType.Pinned); 279public GCHandle _gchandle;
System\Windows\Documents\WinEventHandler.cs (2)
33_gchThis = GCHandle.Alloc(_winEventProc); 165private GCHandle _gchThis;
System\Windows\Standard\MessageWindow.cs (5)
56GCHandle gcHandle = default(GCHandle); 59gcHandle = GCHandle.Alloc(this); 149GCHandle gcHandle = GCHandle.FromIntPtr(createStruct.lpCreateParams);
Roslyn.Test.PdbUtilities (4)
Shared\DummyMetadataImport.cs (4)
22private readonly List<GCHandle> _pinnedBuffers; 41foreach (var pinnedBuffer in _pinnedBuffers) 66GCHandle pinnedBuffer = GCHandle.Alloc(signature, GCHandleType.Pinned);
System.Net.Quic (34)
System\Net\Quic\Internal\MsQuicSafeHandle.cs (2)
91private GCHandle _context; 112public unsafe MsQuicContextSafeHandle(QUIC_HANDLE* handle, GCHandle context, SafeHandleType safeHandleType, MsQuicSafeHandle? parent = null)
System\Net\Quic\Internal\ResettableValueTaskSource.cs (5)
34private GCHandle _keepAlive; 102_keepAlive = GCHandle.Alloc(keepAlive); 324GCHandle handle = GCHandle.Alloc(keepAlive); 327((GCHandle)state!).Free();
System\Net\Quic\Internal\ValueTaskSource.cs (2)
28private GCHandle _keepAlive; 85_keepAlive = GCHandle.Alloc(keepAlive);
System\Net\Quic\QuicConnection.cs (10)
318GCHandle context = GCHandle.Alloc(this, GCHandleType.Weak); 325(void*)GCHandle.ToIntPtr(context), 352GCHandle context = GCHandle.Alloc(this, GCHandleType.Weak); 360(void*)GCHandle.ToIntPtr(context)); 574GCHandle keepObject = GCHandle.Alloc(this); 789GCHandle stateHandle = GCHandle.FromIntPtr((IntPtr)context);
System\Net\Quic\QuicListener.cs (7)
121GCHandle context = GCHandle.Alloc(this, GCHandleType.Weak); 128(void*)GCHandle.ToIntPtr(context), 180GCHandle keepObject = GCHandle.Alloc(this); 371GCHandle stateHandle = GCHandle.FromIntPtr((IntPtr)context);
System\Net\Quic\QuicStream.cs (8)
168GCHandle context = GCHandle.Alloc(this, GCHandleType.Weak); 176(void*)GCHandle.ToIntPtr(context), 210GCHandle context = GCHandle.Alloc(this, GCHandleType.Weak); 221(void*)GCHandle.ToIntPtr(context)); 675GCHandle stateHandle = GCHandle.FromIntPtr((IntPtr)context);
System.Net.Requests (2)
System\Net\TimerThread.cs (2)
207_thisHandle = (IntPtr)GCHandle.Alloc(this); 247((GCHandle)_thisHandle).Free();
System.Net.Security (12)
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.OpenSsl.cs (9)
387GCHandle alpnHandle = default; 422alpnHandle = GCHandle.Alloc(sslAuthenticationOptions.ApplicationProtocols); 423Interop.Ssl.SslSetData(sslHandle, GCHandle.ToIntPtr(alpnHandle)); 742GCHandle protocolHandle = GCHandle.FromIntPtr(sslData); 804GCHandle gch = GCHandle.FromIntPtr(ptr); 834GCHandle gch = GCHandle.FromIntPtr(ptr);
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.Ssl.cs (1)
361public GCHandle AlpnHandle;
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.SslCtx.cs (2)
74private GCHandle _gch; 162_gch = GCHandle.Alloc(this);
System.Net.Sockets (12)
System\Net\Sockets\SocketPal.Unix.cs (12)
299Span<GCHandle> handles = allocOnStack ? stackalloc GCHandle[IovStackThreshold] : new GCHandle[maxBuffers]; 311handles[i] = GCHandle.Alloc(buffer.Array, GCHandleType.Pinned); 411Span<GCHandle> handles = allocOnStack ? stackalloc GCHandle[IovStackThreshold] : new GCHandle[maxBuffers]; 425handles[i] = GCHandle.Alloc(buffer.Array, GCHandleType.Pinned); 553Span<GCHandle> handles = allocOnStack ? stackalloc GCHandle[IovStackThreshold] : new GCHandle[buffersCount]; 564handles[i] = GCHandle.Alloc(buffer.Array, GCHandleType.Pinned);
System.Numerics.Tensors (2)
System\Numerics\Tensors\netcore\Tensor_1.cs (2)
241GCHandle handle = GCHandle.Alloc(_values, GCHandleType.Pinned);
System.Private.CoreLib (121)
src\libraries\System.Private.CoreLib\src\System\Buffers\MemoryHandle.cs (2)
14private GCHandle _handle; 24public MemoryHandle(void* pointer, GCHandle handle = default, IPinnable? pinnable = default)
src\libraries\System.Private.CoreLib\src\System\ComAwareWeakReference.cs (12)
86GCHandle.InternalFree(_weakHandle); 98GCHandle.InternalSet(_weakHandle, target); 103internal object? Target => GCHandle.InternalGet(_weakHandle) ?? RehydrateTarget(); 113target = GCHandle.InternalGet(_weakHandle); 119GCHandle.InternalSet(_weakHandle, target); 133nint newHandle = GCHandle.InternalAlloc(newRef, GCHandleType.Normal); 142GCHandle.InternalFree(newHandle); 146return Unsafe.As<ComAwareWeakReference>(GCHandle.InternalGet(taggedHandle & ~HandleTagBits)); 153return Unsafe.As<ComAwareWeakReference>(GCHandle.InternalGet(taggedHandle & ~HandleTagBits)).Target; 159return Unsafe.As<ComAwareWeakReference>(GCHandle.InternalGet(taggedHandle & ~HandleTagBits))._weakHandle; 167Unsafe.As<ComAwareWeakReference>(GCHandle.InternalGet(taggedHandle & ~HandleTagBits)); 177nint newHandle = GCHandle.InternalAlloc(comAwareRef, GCHandleType.Normal);
src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\EventProvider.cs (3)
615GCHandle[] rgGCHandle = new GCHandle[refObjIndex]; 620rgGCHandle[i] = GCHandle.Alloc(dataRefObj[i], GCHandleType.Pinned);
src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\TraceLogging\DataCollector.cs (5)
26private GCHandle* pinsEnd; 30private GCHandle* pins; 41GCHandle* pins, 311GCHandle* pinsTemp = this.pins; 326*pinsTemp = GCHandle.Alloc(value, GCHandleType.Pinned);
src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\TraceLogging\TraceLoggingEventSource.cs (5)
431GCHandle* pins = stackalloc GCHandle[pinCount]; 609GCHandle* pins = stackalloc GCHandle[pinCount]; 720private static unsafe void WriteCleanup(GCHandle* pPins, int cPins)
src\libraries\System.Private.CoreLib\src\System\IO\PinnedBufferMemoryStream.cs (2)
15private GCHandle _pinningHandle; 22_pinningHandle = GCHandle.Alloc(array, GCHandleType.Pinned);
src\libraries\System.Private.CoreLib\src\System\Memory.cs (4)
401GCHandle handle = GCHandle.Alloc(tmpObject, GCHandleType.Pinned); 420GCHandle handle = GCHandle.Alloc(tmpObject, GCHandleType.Pinned);
src\libraries\System.Private.CoreLib\src\System\ReadOnlyMemory.cs (4)
316GCHandle handle = GCHandle.Alloc(tmpObject, GCHandleType.Pinned); 335GCHandle handle = GCHandle.Alloc(tmpObject, GCHandleType.Pinned);
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\GCHandle.cs (13)
28public partial struct GCHandle : IEquatable<GCHandle> 65public static GCHandle Alloc(object? value) => new GCHandle(value, GCHandleType.Normal); 72public static GCHandle Alloc(object? value, GCHandleType type) => new GCHandle(value, type); 156public static explicit operator GCHandle(IntPtr value) => FromIntPtr(value); 158public static GCHandle FromIntPtr(IntPtr value) 165public static explicit operator IntPtr(GCHandle value) => ToIntPtr(value); 167public static IntPtr ToIntPtr(GCHandle value) => value._handle; 171public override readonly bool Equals([NotNullWhen(true)] object? o) => o is GCHandle other && Equals(other); 176public readonly bool Equals(GCHandle other) => _handle == other._handle; 178public static bool operator ==(GCHandle a, GCHandle b) => a._handle == b._handle; 180public static bool operator !=(GCHandle a, GCHandle b) => a._handle != b._handle;
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\GCHandle.T.cs (9)
21/// <seealso cref="GCHandle" /> 35_handle = GCHandle.InternalAlloc(target, GCHandleType.Normal); 50GCHandle.CheckUninitialized(handle); 52return Unsafe.As<T>(GCHandle.InternalGet(handle)); 57GCHandle.CheckUninitialized(handle); 58GCHandle.InternalSet(handle, value); 71/// interchangable with <see cref="GCHandle"/>. 83/// interchangable with <see cref="GCHandle"/>. 97GCHandle.InternalFree(handle);
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\ObjectiveC\ObjectiveCMarshal.PlatformNotSupported.cs (2)
89/// The caller is responsible for freeing the returned <see cref="GCHandle"/>. 91public static GCHandle CreateReferenceTrackingHandle(
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\PinnedGCHandle.T.cs (9)
22/// <seealso cref="GCHandle" /> 37_handle = GCHandle.InternalAlloc(target, GCHandleType.Pinned); 52GCHandle.CheckUninitialized(handle); 54return Unsafe.As<T>(GCHandle.InternalGet(handle)); 59GCHandle.CheckUninitialized(handle); 61GCHandle.InternalSet(handle, value); 105/// interchangable with <see cref="GCHandle"/>. 117/// interchangable with <see cref="GCHandle"/>. 131GCHandle.InternalFree(handle);
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\WeakGCHandle.T.cs (9)
21/// <seealso cref="GCHandle" /> 36_handle = GCHandle.InternalAlloc(target, trackResurrection ? GCHandleType.WeakTrackResurrection : GCHandleType.Weak); 54GCHandle.CheckUninitialized(handle); 56T? obj = Unsafe.As<T?>(GCHandle.InternalGet(handle)); 66GCHandle.CheckUninitialized(handle); 67GCHandle.InternalSet(handle, target); 79/// interchangable with <see cref="GCHandle"/>. 91/// interchangable with <see cref="GCHandle"/>. 105GCHandle.InternalFree(handle);
src\libraries\System.Private.CoreLib\src\System\Runtime\Loader\AssemblyLoadContext.cs (7)
101var thisHandle = GCHandle.Alloc(this, IsCollectible ? GCHandleType.WeakTrackResurrection : GCHandleType.Normal); 102var thisHandlePtr = GCHandle.ToIntPtr(thisHandle); 147var thisStrongHandle = GCHandle.Alloc(this, GCHandleType.Normal); 148var thisStrongHandlePtr = GCHandle.ToIntPtr(thisStrongHandle); 609AssemblyLoadContext context = (AssemblyLoadContext)(GCHandle.FromIntPtr(gchManagedAssemblyLoadContext).Target)!;
src\libraries\System.Private.CoreLib\src\System\Threading\Overlapped.cs (6)
150(nuint)(sizeof(NativeOverlapped) + sizeof(nuint)) + handleCount * (nuint)sizeof(GCHandle)); 160GCHandleRef(pNativeOverlapped, 0) = GCHandle.Alloc(this); 170GCHandleRef(pNativeOverlapped, (nuint)(i + 1)) = GCHandle.Alloc(objArray[i], GCHandleType.Pinned); 176GCHandleRef(pNativeOverlapped, 1) = GCHandle.Alloc(userData, GCHandleType.Pinned); 221private static ref GCHandle GCHandleRef(NativeOverlapped* pNativeOverlapped, nuint index) 222=> ref *((GCHandle*)((nuint*)(pNativeOverlapped + 1) + 1) + index);
src\libraries\System.Private.CoreLib\src\System\Threading\Win32ThreadPoolNativeOverlapped.cs (3)
140data._pinnedData[i] = GCHandle.Alloc(objArray[i], GCHandleType.Pinned); 147data._pinnedData ??= new GCHandle[1]; 150data._pinnedData[0] = GCHandle.Alloc(pinData, GCHandleType.Pinned);
src\libraries\System.Private.CoreLib\src\System\Threading\Win32ThreadPoolNativeOverlapped.OverlappedData.cs (1)
13internal GCHandle[]? _pinnedData;
src\libraries\System.Private.CoreLib\src\System\WeakReference.cs (5)
83nint h = GCHandle.InternalAlloc(target, trackResurrection ? GCHandleType.WeakTrackResurrection : GCHandleType.Weak); 129bool result = GCHandle.InternalGet(wh) != null; 175target = GCHandle.InternalGet(th); 206GCHandle.InternalSet(th, value); 228GCHandle.InternalFree(handle);
src\libraries\System.Private.CoreLib\src\System\WeakReference.T.cs (3)
83nint h = GCHandle.InternalAlloc(target, trackResurrection ? GCHandleType.WeakTrackResurrection : GCHandleType.Weak); 120GCHandle.InternalSet(th, target); 154target = Unsafe.As<T?>(GCHandle.InternalGet(th));
src\System\GC.CoreCLR.cs (1)
291object? obj = GCHandle.InternalGet(wo.WeakHandle);
src\System\MulticastDelegate.CoreCLR.cs (3)
601this._methodBase = GCHandle.InternalGet(gchandle); 611this._methodBase = GCHandle.InternalGet(gchandle); 620this._methodBase = GCHandle.InternalGet(gchandle);
src\System\Runtime\CompilerServices\AsyncHelpers.CoreCLR.cs (1)
150gcData[numGCRefs] = GCHandle.FromIntPtr(loaderAllocatorHandle).Target;
src\System\Runtime\CompilerServices\StaticsHelpers.cs (1)
205object? threadStaticObject = GCHandle.InternalGet(objHandle);
src\System\Runtime\InteropServices\ComWrappers.cs (1)
97return Unsafe.As<T>(GCHandle.InternalGet(comInstance->GcHandle));
src\System\Runtime\Loader\AssemblyLoadContext.CoreCLR.cs (5)
115AssemblyLoadContext context = (AssemblyLoadContext)(GCHandle.FromIntPtr(gchManagedAssemblyLoadContext).Target)!; 125AssemblyLoadContext context = (AssemblyLoadContext)(GCHandle.FromIntPtr(gchManagedAssemblyLoadContext).Target)!; 133AssemblyLoadContext context = (AssemblyLoadContext)(GCHandle.FromIntPtr(gchManagedAssemblyLoadContext).Target)!; 141AssemblyLoadContext context = (AssemblyLoadContext)(GCHandle.FromIntPtr(gchManagedAssemblyLoadContext).Target)!; 170loadContextForAssembly = (AssemblyLoadContext)(GCHandle.FromIntPtr(ptrAssemblyLoadContext).Target)!;
src\System\RuntimeType.CoreCLR.cs (5)
2422object? cache = GCHandle.InternalGet(m_cache); 2437object? cache = GCHandle.InternalGet(m_cache); 2460RuntimeTypeCache? cache = (RuntimeTypeCache?)GCHandle.InternalGet(m_cache); 2464RuntimeTypeCache? existingCache = (RuntimeTypeCache?)GCHandle.InternalCompareExchange(m_cache, cache, null); 2482GCHandle.InternalSet(m_cache, null);
System.Private.Windows.Core (19)
Windows\Win32\PInvokeCore.EnumChildWindows.cs (3)
19GCHandle gcHandle = GCHandle.Alloc(callback); 34return ((EnumChildWindowsCallback)((GCHandle)(nint)lParam).Target!)(hWnd);
Windows\Win32\PInvokeCore.EnumDisplayMonitors.cs (3)
15GCHandle gcHandle = GCHandle.Alloc(callBack); 29return ((EnumDisplayMonitorsCallback)((GCHandle)(nint)lParam).Target!)(monitor, hdc);
Windows\Win32\PInvokeCore.EnumThreadWindows.cs (3)
21GCHandle gcHandle = GCHandle.Alloc(callback); 35return ((EnumThreadWindowsCallback)((GCHandle)(nint)lParam).Target!)(hWnd);
Windows\Win32\PInvokeCore.EnumWindows.cs (3)
18GCHandle gcHandle = GCHandle.Alloc(callback); 32return ((EnumWindowsCallback)((GCHandle)(nint)lParam).Target!)(hWnd);
Windows\Win32\System\Com\Lifetime.cs (5)
33GCHandle.FromIntPtr((nint)lifetime->_handle).Free(); 46/// This creates a <see cref="GCHandle"/> to root the <paramref name="object"/> until ref 60wrapper->_handle = (void*)GCHandle.ToIntPtr(GCHandle.Alloc(@object)); 77return (TObject?)GCHandle.FromIntPtr((IntPtr)lifetime->_handle).Target;
Windows\Win32\System\Variant\VARIANT.cs (2)
264GCHandle pin = default; 268pin = GCHandle.Alloc(array, GCHandleType.Pinned);
System.Reflection.Metadata (5)
System\Reflection\Internal\Utilities\PinnedObject.cs (2)
13private GCHandle _handle; 28_handle = GCHandle.Alloc(obj, GCHandleType.Pinned);
System\Reflection\Metadata\Internal\VirtualHeap.cs (3)
24public GCHandle Handle; 28public PinnedBlob(GCHandle handle, int length) 103var blob = new PinnedBlob(GCHandle.Alloc(value, GCHandleType.Pinned), value.Length);
System.Resources.Extensions (2)
src\libraries\System.Private.CoreLib\src\System\IO\PinnedBufferMemoryStream.cs (2)
15private GCHandle _pinningHandle; 22_pinningHandle = GCHandle.Alloc(array, GCHandleType.Pinned);
System.Runtime (1)
artifacts\obj\System.Runtime\Debug\net10.0\System.Runtime.Forwards.cs (1)
666[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.InteropServices.GCHandle))]
System.Runtime.Caching (2)
System\Runtime\Caching\SRef.cs (2)
31private GCHandle _handle; 36_handle = GCHandle.Alloc(t);
System.Runtime.InteropServices (1)
artifacts\obj\System.Runtime.InteropServices\Debug\net10.0\System.Runtime.InteropServices.Forwards.cs (1)
90[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.InteropServices.GCHandle))]
System.Security.Cryptography (2)
System\Security\Cryptography\CryptoStream.cs (2)
724GCHandle pinHandle = GCHandle.Alloc(rentedBuffer, GCHandleType.Pinned);
System.Windows.Forms (22)
System\Windows\Forms\Control.ControlNativeWindow.cs (2)
13private GCHandle _rootRef; // We will root the control when we do not want to be eligible for garbage collection. 43_rootRef = GCHandle.Alloc(GetControl(), GCHandleType.Normal);
System\Windows\Forms\Dialogs\CommonDialogs\FolderBrowserDialog.cs (4)
453GCHandle handle = GCHandle.Alloc(this); 463GCHandle.ToIntPtr(handle)); 494var instance = (FolderBrowserDialog)GCHandle.FromIntPtr(lpData).Target!;
System\Windows\Forms\Dialogs\TaskDialog\TaskDialog.cs (4)
82/// The <see cref="IntPtr"/> of a <see cref="GCHandle"/> that represents this 277(((GCHandle)lpRefData).Target as TaskDialog)!.HandleTaskDialogCallback( 563var instanceHandle = GCHandle.Alloc(this);
System\Windows\Forms\NativeWindow.cs (8)
38private static readonly Dictionary<HWND, GCHandle> s_windowHandles = []; 245GCHandle root = GCHandle.Alloc(window, GCHandleType.Weak); 247if (s_windowHandles.TryGetValue(handle, out GCHandle oldRoot)) 561s_windowHandles.TryGetValue(handle, out GCHandle value) && value.IsAllocated 613foreach ((HWND handle, GCHandle gcHandle) in s_windowHandles) 708if (!s_windowHandles.TryGetValue(hwnd, out GCHandle root)) 735s_windowHandles[hwnd] = GCHandle.Alloc(window.PreviousWindow, GCHandleType.Weak);
System\Windows\Forms\NotifyIcon.NotifyIconNativeWindow.cs (2)
16private GCHandle _rootRef; // We will root the control when we do not want to be eligible for garbage collection. 43_rootRef = GCHandle.Alloc(_reference, GCHandleType.Normal);
System\Windows\Forms\Timer.cs (2)
25private GCHandle _timerRoot; 114_timerRoot = GCHandle.Alloc(this);
System.Windows.Forms.Primitives (4)
Windows\Win32\PInvoke.SendMessageCallback.cs (4)
19GCHandle gcHandle = GCHandle.Alloc(callback); 28GCHandle gcHandle = (GCHandle)(nint)dwData;
System.Windows.Forms.Primitives.TestUtilities (4)
Metafiles\EmfScope.cs (4)
79GCHandle enumeratorHandle = GCHandle.Alloc(enumerator); 241GCHandle enumeratorHandle = GCHandle.FromIntPtr(data);
System.Windows.Forms.TestUtilities (4)
PropertyGridInternal\SubPropertyGrid.cs (4)
48var callbackHandle = GCHandle.Alloc(() => 66PInvokeCore.PostMessage(this, WM_DELAYEDEXECUTION, lParam: GCHandle.ToIntPtr(callbackHandle)); 102((Action)GCHandle.FromIntPtr(m.LParamInternal).Target!)();
TlsFeaturesObserve (6)
HttpSys\HttpSysConfigurator.cs (6)
29var sockAddrHandle = CreateSockaddrStructure(ipPort); 34var handleHash = GCHandle.Alloc(hash, GCHandleType.Pinned); 86static GCHandle CreateSockaddrStructure(IPEndPoint ipEndPoint) 92var sockAddrHandle = GCHandle.Alloc(sockAddrStructureBytes, GCHandleType.Pinned);
UIAutomationClient (8)
MS\Internal\Automation\EventListenerClientSide.cs (2)
32_gch = GCHandle.Alloc(_callbackDelegate); 294private GCHandle _gch; // GCHandle to keep GCs from moving the callback
MS\Internal\Automation\HwndProxyElementProvider.cs (2)
1576GCHandle gch = GCHandle.Alloc(enumWindows);
MS\Internal\Automation\UiaCoreApi.cs (2)
1555private static GCHandle _gchandle; 1560_gchandle = GCHandle.Alloc(onGetProviderDelegate);
MS\Internal\Automation\WinEventWrap.cs (2)
240_gchThis = GCHandle.Alloc(_winEventProc); 280private GCHandle _gchThis; // GCHandle to keep GCs from moving this callback
UIAutomationClientSideProviders (6)
MS\Internal\AutomationProxies\Misc.cs (2)
349GCHandle gch = GCHandle.Alloc(enumToolTipWindows);
MS\Internal\AutomationProxies\MSAAWinEventWrap.cs (2)
171_gchThis = GCHandle.Alloc(_winEventProc); 221private GCHandle _gchThis; // GCHandle to keep GCs from moving this callback
MS\Internal\AutomationProxies\WinEventTracker.cs (2)
124internal GCHandle _procHookHandle; 173hp._procHookHandle = GCHandle.Alloc (proc);