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);
398 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)
26private GCHandle _httpServerHandle; 98_httpServerHandle = GCHandle.Alloc(this); 157server = (IISHttpServer?)GCHandle.FromIntPtr(pvRequestContext).Target; 188server = (IISHttpServer?)GCHandle.FromIntPtr(pvRequestContext).Target; 212context = (IISHttpContext?)GCHandle.FromIntPtr(pvManagedHttpContext).Target; 234context = (IISHttpContext?)GCHandle.FromIntPtr(pvManagedHttpContext).Target; 259server = (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)
1068var gcHandleType = _emptyCompilation.GetTypeByMetadataName(typeof(GCHandle).FullName);
Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities (1)
BlindAggregatorFactory.cs (1)
70GCHandle.FromIntPtr(_gcHandle).Free();
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)
975var featureBufferHandle = GCHandle.Alloc(featuresBuffer, GCHandleType.Pinned); 977var labelBufferHandle = GCHandle.Alloc(labelBuffer, GCHandleType.Pinned);
Microsoft.NET.StringTools (2)
WeakStringCache.cs (2)
36private GCHandle weakHandle; 80weakHandle = GCHandle.Alloc(str, GCHandleType.Weak);
Microsoft.NET.StringTools.net35 (2)
WeakStringCache.cs (2)
36private GCHandle weakHandle; 80weakHandle = 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
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); 162private 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.Drawing.Common (2)
System\Drawing\Font.cs (2)
293GCHandle handle = GCHandle.Alloc(logFont, 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)
319GCHandle context = GCHandle.Alloc(this, GCHandleType.Weak); 326(void*)GCHandle.ToIntPtr(context), 353GCHandle context = GCHandle.Alloc(this, GCHandleType.Weak); 361(void*)GCHandle.ToIntPtr(context)); 572GCHandle keepObject = GCHandle.Alloc(this); 784GCHandle stateHandle = GCHandle.FromIntPtr((IntPtr)context);
System\Net\Quic\QuicListener.cs (7)
123GCHandle context = GCHandle.Alloc(this, GCHandleType.Weak); 130(void*)GCHandle.ToIntPtr(context), 182GCHandle keepObject = GCHandle.Alloc(this); 373GCHandle 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)
391GCHandle alpnHandle = default; 431alpnHandle = GCHandle.Alloc(sslAuthenticationOptions.ApplicationProtocols); 432Interop.Ssl.SslSetData(sslHandle, GCHandle.ToIntPtr(alpnHandle)); 886GCHandle protocolHandle = GCHandle.FromIntPtr(sslData); 948GCHandle gch = GCHandle.FromIntPtr(ptr); 978GCHandle gch = GCHandle.FromIntPtr(ptr);
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.Ssl.cs (1)
385public GCHandle AlpnHandle;
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.SslCtx.cs (2)
75private GCHandle _gch; 163_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)
210GCHandle handle = GCHandle.Alloc(_values, GCHandleType.Pinned);
System.Private.CoreLib (152)
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 (11)
86GCHandle.InternalFree(_weakHandle); 98GCHandle.InternalSet(_weakHandle, target); 103internal object? Target => GCHandle.InternalGet(_weakHandle); 115target = Unsafe.As<T?>(GCHandle.InternalGet(_weakHandle)); 122GCHandle.InternalSet(_weakHandle, target); 136nint newHandle = GCHandle.InternalAlloc(newRef, GCHandleType.Normal); 145GCHandle.InternalFree(newHandle); 149return Unsafe.As<ComAwareWeakReference>(GCHandle.InternalGet(taggedHandle & ~HandleTagBits)); 156return Unsafe.As<ComAwareWeakReference>(GCHandle.InternalGet(taggedHandle & ~HandleTagBits)); 164Unsafe.As<ComAwareWeakReference>(GCHandle.InternalGet(taggedHandle & ~HandleTagBits)); 174nint 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\ComWrappers.cs (25)
229return Unsafe.As<ManagedObjectWrapperHolder>(GCHandle.FromIntPtr(handle).Target); 380GCHandle.InternalFree(handle); 516if (refCountedHandle != IntPtr.Zero && GCHandle.InternalGet(refCountedHandle) != null) 546private GCHandle _proxyHandle; 547private GCHandle _proxyHandleTrackingResurrection; 592_proxyHandle = GCHandle.Alloc(comProxy, GCHandleType.Weak); 599_proxyHandleTrackingResurrection = GCHandle.Alloc(comProxy, GCHandleType.WeakTrackResurrection); 615internal GCHandle ProxyHandle => _proxyHandle; 668internal readonly GCHandle _nativeObjectWrapperWeakHandle; 700_nativeObjectWrapperWeakHandle = GCHandle.Alloc(this, GCHandleType.Weak); 1293private readonly Dictionary<IntPtr, GCHandle> _cache = []; 1308ref GCHandle rcwEntry = ref CollectionsMarshal.GetValueRefOrAddDefault(_cache, comPointer, out bool exists); 1313rcwEntry = GCHandle.Alloc(wrapper, GCHandleType.Weak); 1351if (_cache.TryGetValue(comPointer, out GCHandle existingHandle)) 1382if (_cache.TryGetValue(comPointer, out GCHandle cachedRef) 1626internal sealed class GCHandleSet : IEnumerable<GCHandle> 1636public void Add(GCHandle handle) 1710public void Remove(GCHandle handle) 1739private static int GetBucket(GCHandle handle, int numBuckets) 1747IEnumerator<GCHandle> IEnumerable<GCHandle>.GetEnumerator() => GetEnumerator(); 1749IEnumerator IEnumerable.GetEnumerator() => ((IEnumerable<GCHandle>)this).GetEnumerator(); 1754public GCHandle _value; 1757public struct Enumerator : IEnumerator<GCHandle> 1772public GCHandle Current
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\TrackerObjectManager.cs (1)
73foreach (GCHandle weakNativeObjectWrapperHandle in s_referenceTrackerNativeObjectWrapperCache)
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(gchAssemblyLoadContext).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); 130bool result = GCHandle.InternalGetBridgeWait(wh) != null; 181target = GCHandle.InternalGetBridgeWait(th); 216GCHandle.InternalSet(th, value); 238GCHandle.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); 157target = Unsafe.As<T?>(GCHandle.InternalGetBridgeWait(th));
src\System\GC.CoreCLR.cs (1)
298object? obj = GCHandle.InternalGet(wo.WeakHandle);
src\System\MulticastDelegate.CoreCLR.cs (3)
602this._methodBase = GCHandle.InternalGet(gchandle); 612this._methodBase = GCHandle.InternalGet(gchandle); 621this._methodBase = GCHandle.InternalGet(gchandle);
src\System\Runtime\CompilerServices\AsyncHelpers.CoreCLR.cs (1)
182gcData[numGCRefs] = GCHandle.FromIntPtr(loaderAllocatorHandle).Target;
src\System\Runtime\CompilerServices\StaticsHelpers.cs (1)
205object? threadStaticObject = GCHandle.InternalGet(objHandle);
src\System\Runtime\InteropServices\GCHandle.CoreCLR.cs (1)
49if (GCHandle.InternalTryGetBridgeWait(handle, ref target))
src\System\Runtime\InteropServices\Java\JavaMarshal.CoreCLR.cs (6)
23public static unsafe GCHandle CreateReferenceTrackingHandle(object obj, void* context) 28return GCHandle.FromIntPtr(handle); 31public static unsafe void* GetContext(GCHandle obj) 33IntPtr handle = GCHandle.ToIntPtr(obj); 45ReadOnlySpan<GCHandle> unreachableObjectHandles) 47fixed (GCHandle* pHandles = unreachableObjectHandles)
src\System\Runtime\Loader\AssemblyLoadContext.CoreCLR.cs (5)
115AssemblyLoadContext context = (AssemblyLoadContext)(GCHandle.FromIntPtr(gchAssemblyLoadContext).Target)!; 125AssemblyLoadContext context = (AssemblyLoadContext)(GCHandle.FromIntPtr(gchAssemblyLoadContext).Target)!; 133AssemblyLoadContext context = (AssemblyLoadContext)(GCHandle.FromIntPtr(gchAssemblyLoadContext).Target)!; 141AssemblyLoadContext context = (AssemblyLoadContext)(GCHandle.FromIntPtr(gchAssemblyLoadContext).Target)!; 170loadContextForAssembly = (AssemblyLoadContext)(GCHandle.FromIntPtr(ptrAssemblyLoadContext).Target)!;
src\System\RuntimeType.CoreCLR.cs (5)
2398object? cache = GCHandle.InternalGet(m_cache); 2413object? cache = GCHandle.InternalGet(m_cache); 2436RuntimeTypeCache? cache = (RuntimeTypeCache?)GCHandle.InternalGet(m_cache); 2440RuntimeTypeCache? existingCache = (RuntimeTypeCache?)GCHandle.InternalCompareExchange(m_cache, cache, null); 2458GCHandle.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)
670[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)
91[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)
81/// The <see cref="IntPtr"/> of a <see cref="GCHandle"/> that represents this 276(((GCHandle)lpRefData).Target as TaskDialog)!.HandleTaskDialogCallback( 559var 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);