4 instantiations of GCHandle
PresentationCore (1)
src\Microsoft.DotNet.Wpf\src\Shared\MS\Internal\CharacterBuffer.cs (1)
429gcHandle = new GCHandle();
System.Private.CoreLib (3)
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\GCHandle.cs (3)
62public static GCHandle Alloc(object? value) => new GCHandle(value, GCHandleType.Normal); 69public static GCHandle Alloc(object? value, GCHandleType type) => new GCHandle(value, type); 158return new GCHandle(value);
338 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; 97_httpServerHandle = GCHandle.Alloc(this); 153server = (IISHttpServer?)GCHandle.FromIntPtr(pvRequestContext).Target; 184server = (IISHttpServer?)GCHandle.FromIntPtr(pvRequestContext).Target; 208context = (IISHttpContext?)GCHandle.FromIntPtr(pvManagedHttpContext).Target; 230context = (IISHttpContext?)GCHandle.FromIntPtr(pvManagedHttpContext).Target; 255server = (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)
988var 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; 69WeakHandle = GCHandle.Alloc(str, GCHandleType.Weak);
Microsoft.NET.StringTools.net35 (2)
WeakStringCache.cs (2)
36public GCHandle WeakHandle; 69WeakHandle = 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)
378_memoryHandle = GCHandle.Alloc(bits, GCHandleType.Pinned); 404private GCHandle _memoryHandle;
MS\Internal\Shaping\TypefaceMap.cs (1)
92GCHandle gcHandle;
src\Microsoft.DotNet.Wpf\src\Shared\MS\Internal\CharacterBuffer.cs (10)
40public abstract IntPtr PinAndGetCharacterPointer(int offset, out GCHandle gcHandle); 45public abstract void UnpinCharacterPointer(GCHandle gcHandle); 219public unsafe override IntPtr PinAndGetCharacterPointer(int offset, out GCHandle gcHandle) 221gcHandle = GCHandle.Alloc(_characterArray, GCHandleType.Pinned); 228public override void UnpinCharacterPointer(GCHandle gcHandle) 318public unsafe override IntPtr PinAndGetCharacterPointer(int offset, out GCHandle gcHandle) 320gcHandle = GCHandle.Alloc(_string, GCHandleType.Pinned); 327public override void UnpinCharacterPointer(GCHandle gcHandle) 427public override IntPtr PinAndGetCharacterPointer(int offset, out GCHandle gcHandle) 436public override void UnpinCharacterPointer(GCHandle gcHandle)
System\Windows\Media\EventProxy.cs (5)
32((System.Runtime.InteropServices.GCHandle)(pEPD.m_handle)).Free(); 35internal System.Runtime.InteropServices.GCHandle m_handle; 106System.Runtime.InteropServices.GCHandle handle = (System.Runtime.InteropServices.GCHandle)(epd.m_handle); 139m_handle = System.Runtime.InteropServices.GCHandle.Alloc(epw, System.Runtime.InteropServices.GCHandleType.Normal)
System\Windows\Media\StreamAsIStream.cs (5)
56((System.Runtime.InteropServices.GCHandle)(pSD.m_handle)).Free(); 59internal System.Runtime.InteropServices.GCHandle m_handle; 511System.Runtime.InteropServices.GCHandle handle = (System.Runtime.InteropServices.GCHandle)(sd.m_handle); 658sd.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)
34_gchThis = GCHandle.Alloc(_winEventProc); 166private GCHandle _gchThis;
System\Windows\Standard\MessageWindow.cs (5)
57GCHandle gcHandle = default(GCHandle); 60gcHandle = GCHandle.Alloc(this); 150GCHandle 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); 323GCHandle handle = GCHandle.Alloc(keepAlive); 326((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); 777GCHandle 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; 403alpnHandle = GCHandle.Alloc(sslAuthenticationOptions.ApplicationProtocols); 404Interop.Ssl.SslSetData(sslHandle, GCHandle.ToIntPtr(alpnHandle)); 732GCHandle protocolHandle = GCHandle.FromIntPtr(sslData); 794GCHandle gch = GCHandle.FromIntPtr(ptr); 824GCHandle gch = GCHandle.FromIntPtr(ptr);
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.Ssl.cs (1)
354public 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.Private.CoreLib (101)
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\EventPipeEventProvider.cs (4)
13private GCHandle _gcHandle; 65EventPipeEventProvider _this = (EventPipeEventProvider)GCHandle.FromIntPtr((IntPtr)callbackContext).Target!; 76_gcHandle = GCHandle.Alloc(this); 78_provHandle = EventPipeInternal.CreateProvider(name, &Callback, (void*)GCHandle.ToIntPtr(_gcHandle));
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\Gen2GcCallback.cs (2)
18private GCHandle _weakTargetObj; 28_weakTargetObj = GCHandle.Alloc(targetObj, GCHandleType.Weak);
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)
25public partial struct GCHandle : IEquatable<GCHandle> 62public static GCHandle Alloc(object? value) => new GCHandle(value, GCHandleType.Normal); 69public static GCHandle Alloc(object? value, GCHandleType type) => new GCHandle(value, type); 153public static explicit operator GCHandle(IntPtr value) => FromIntPtr(value); 155public static GCHandle FromIntPtr(IntPtr value) 162public static explicit operator IntPtr(GCHandle value) => ToIntPtr(value); 164public static IntPtr ToIntPtr(GCHandle value) => value._handle; 168public override readonly bool Equals([NotNullWhen(true)] object? o) => o is GCHandle other && Equals(other); 173public readonly bool Equals(GCHandle other) => _handle == other._handle; 175public static bool operator ==(GCHandle a, GCHandle b) => a._handle == b._handle; 177public static bool operator !=(GCHandle a, GCHandle b) => a._handle != b._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\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 (3)
296object? obj = GCHandle.InternalGet(wo.WeakHandle); 676public GCHandle action; 712pWorkItem->action = GCHandle.Alloc(callback);
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\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 (14)
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\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)
650[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 (4)
System\Security\Cryptography\CryptoStream.cs (2)
724GCHandle pinHandle = GCHandle.Alloc(rentedBuffer, GCHandleType.Pinned);
System\Security\Cryptography\PinAndClear.cs (2)
11private GCHandle _gcHandle; 17_gcHandle = GCHandle.Alloc(
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) 711if (!s_windowHandles.TryGetValue(hwnd, out GCHandle root)) 741s_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!)();
UIAutomationClient (8)
MS\Internal\Automation\EventListenerClientSide.cs (2)
33_gch = GCHandle.Alloc(_callbackDelegate); 295private GCHandle _gch; // GCHandle to keep GCs from moving the callback
MS\Internal\Automation\HwndProxyElementProvider.cs (2)
1577GCHandle gch = GCHandle.Alloc(enumWindows);
MS\Internal\Automation\UiaCoreApi.cs (2)
1556static GCHandle _gchandle; 1561_gchandle = GCHandle.Alloc(onGetProviderDelegate);
MS\Internal\Automation\WinEventWrap.cs (2)
241_gchThis = GCHandle.Alloc(_winEventProc); 281private GCHandle _gchThis; // GCHandle to keep GCs from moving this callback
UIAutomationClientSideProviders (6)
MS\Internal\AutomationProxies\Misc.cs (2)
350GCHandle gch = GCHandle.Alloc(enumToolTipWindows);
MS\Internal\AutomationProxies\MSAAWinEventWrap.cs (2)
172_gchThis = GCHandle.Alloc(_winEventProc); 222private GCHandle _gchThis; // GCHandle to keep GCs from moving this callback
MS\Internal\AutomationProxies\WinEventTracker.cs (2)
125internal GCHandle _procHookHandle; 174hp._procHookHandle = GCHandle.Alloc (proc);