首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏EdisonTalk

    .NET Core多线程 (2) 异步 - 上

    SafeHandle:文件句柄、网络句柄... 核心步骤: 初始化时将SafeHandle、ThreadPool与IO完成端口进行绑定(比如:FileStream在Init时) (主线程)创建IO完成端口:CreateIoCompletionPort 创建IO完成端口 var safehandle = IOCP.CreateIoCompletionPort(new IntPtr(-1), IntPtr.Zero, IntPtr.Zero, 1); Environment.CurrentManagedThreadId} 开始获取数据..."); while (true) { // 3. get数据 IOCP.GetQueuedCompletionStatus(safehandle ; // 2. post 数据 var data = (IntPtr)GCHandle.Alloc("hello world"); IOCP.PostQueuedCompletionStatus(safehandle

    66720编辑于 2023-08-09
  • 来自专栏JusterZhu

    WinDbg

    SetLastError = true)] static extern bool MiniDumpWriteDump(IntPtr hProcess, uint processId, SafeHandle SetLastError = true)] static extern bool MiniDumpWriteDump(IntPtr hProcess, uint processId, SafeHandle ExactSpelling = true)] static extern uint GetCurrentThreadId(); static bool Write(SafeHandle fileHandle, (uint)options, ref exp, IntPtr.Zero, IntPtr.Zero); } static bool Write(SafeHandle

    94110编辑于 2022-12-07
  • 来自专栏蘑菇先生的技术笔记

    多线程中的锁系统(三)-WaitHandle、AutoResetEvent、ManualResetEvent

    } [System.Security.SecurityCritical] internal static bool InternalWaitOne(SafeHandle MethodImplAttribute(MethodImplOptions.InternalCall)] private static extern int WaitOneNative(SafeHandle

    2.1K70发布于 2018-05-21
  • 来自专栏测试游记

    FLAG_SECURE:安卓无法抓取页面截屏

    utils.ScreenshotHelper.takeScreenshot(ScreenshotHelper.java:79)\n\tat io.appium.uiautomator2.handler.CaptureScreenshot.safeHandle ScreenshotHelper.java:79) [MJSONWP (669c743a)] at io.appium.uiautomator2.handler.CaptureScreenshot.safeHandle

    4.1K20编辑于 2022-03-29
  • 来自专栏Core Net

    ASP.NET Core 2.1 : 十三.httpClient.GetAsync 报SSL错误的问题

    OpenSslCryptographicException: error:2006D002:BIO routines:BIO_new_file:system lib at Interop.Crypto.CheckValidOpenSslHandle(SafeHandle

    1.5K20发布于 2018-08-20
  • 来自专栏DotNet NB && CloudNative

    微软员工聊C#中的IDisposable接口

    ManualResetEvent,ReaderWriterLockSlim,Semaphore 这些 IDisposable 对象,里面的所谓“资源”,归根结底都是一些很小的 Windows event 对象,而且它们都继承了 SafeHandle SafeHandle 本身有一个“析构函数”(finalizer),它看起来是这个样子: ~SafeHandle() { Dispose(false); } 当 SafeHandle 被 GC 回收的时候

    88240编辑于 2023-10-28
  • 来自专栏林德熙的博客

    WPF 开机启动因为触摸初始化锁住界面显示

    System.Threading.WaitHandle.InternalWaitOne(System.Runtime.InteropServices.SafeHandle waitableSafeHandle System.Threading.WaitHandle.InternalWaitOne(System.Runtime.InteropServices.SafeHandle waitableSafeHandle System.Threading.WaitHandle.InternalWaitOne(System.Runtime.InteropServices.SafeHandle waitableSafeHandle System.Threading.WaitHandle.InternalWaitOne(System.Runtime.InteropServices.SafeHandle waitableSafeHandle System.Threading.WaitHandle.InternalWaitOne(System.Runtime.InteropServices.SafeHandle waitableSafeHandle

    1.2K40发布于 2020-07-06
  • 来自专栏C++ 模板编程:从基础到现代实战

    模板编程高级技巧与实战

    is_pointer_v<T> && std::is_base_of_v<IUnknown, T>;template<HANDLE_TYPE H>void SafeHandle (H handle) { // 只有有效的COM接口指针才能调用 handle->AddRef();}// 使用示例SafeHandle(reinterpret_cast<IUnknown* \\PhysicalDrive0", GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr))); // 编译通过SafeHandle

    82620编辑于 2025-02-20
  • 来自专栏喵叔's 专栏

    如何实现标准的dispose

    Tip:在 .NET 中访问非托管资源还可以通过 System.Runtime.Interop.SafeHandle 的派生类来访问,该类正确实现了标准的 dispose 。

    1.1K20发布于 2020-09-08
  • 来自专栏Dotnet9

    【推荐】.NET类库“Vanara”:简单易用的Windows API封装库

    尽可能,所有句柄都已转换为以Windows API句柄命名的SafeHandle派生工具。 如果这些句柄需要调用函数以释放/关闭/销毁,则存在一个派生的SafeHANDLE,该函数将在disposal时执行该函数。 例如,定义了HTOKEN。 extractions via reflection* Extension and helper methods to marshaling structures arrays and strings* SafeHandle

    2.6K10发布于 2021-12-01
  • 解锁.NET 11 新能:C# 14 在客户端安全编程的革新与实践

    开发者需要手动使用SafeHandle等类来确保非托管资源的安全释放,避免内存泄漏和其他安全问题。

    9800编辑于 2026-05-16
  • 来自专栏鸿鹄实验室

    OffenSive Csharp Development Part1

    CallingConvention.Cdecl)] private delegate bool MiniDumpWriteDump(IntPtr hProcess, uint ProcessId, SafeHandle

    98240发布于 2021-04-01
  • 来自专栏Pulsar-V

    C++/CLI(二)Mono C++/CLI Native调用和P/Invoke调用

    This new mechanism is exposed by the SafeHandle class. SafeHandles encapsulate a handle in the form of an IntPtr, but by exposing it as a subclass of the SafeHandle The behavior depends on its use: On outgoing parameters, the SafeHandle's handle is passed. On return values, a new instance of the concrete SafeHandle class is created, and the handle value is On structure fields, the SafeHandle's handle is passed.

    4.4K30发布于 2019-04-01
  • 来自专栏各类技术文章~

    记一次 .NET 某风控管理系统 内存泄漏分析

    ThreadPoolBoundHandleOverlapped -> System.IO.FileSystemWatcher+AsyncReadState -> Buffer[], 这中间涉及到 ThreadPool 和 SafeHandle

    67950发布于 2021-11-02
  • 来自专栏全栈工程师修炼之路

    PS常用命令之脚本编程常用命令

    string MachineName {get;set;} # ServiceHandle Property System.Runtime.InteropServices.SafeHandle

    2K10发布于 2020-10-23
  • 来自专栏张善友的专栏

    .net 应用迁移到Mono 工具 (Moma)

    , Int64&) SafeFileHandle FileStream.get_SafeFileHandle() bool GetFileInfo(DateTime&, Int64&) IntPtr SafeHandle.DangerousGetHandle NLog.Internal.FileAppenders.MutexMultiProcessFileAppender: bool GetFileInfo(DateTime&, Int64&) IntPtr SafeHandle.DangerousGetHandle

    2.3K80发布于 2018-01-31
  • 来自专栏Angular学习规划

    ASP.NET Core 中的内存管理和垃圾回收 (GC)

    在大多数情况下,通过使用 System.Runtime.InteropServices.SafeHandle 或派生类包装任何非托管句柄,可以免去编写终结器的过程。

    1.4K30编辑于 2023-10-17
  • 来自专栏Angular学习规划

    ASP.NET Core 中的内存管理和垃圾回收 (GC)

    在大多数情况下,通过使用 System.Runtime.InteropServices.SafeHandle 或派生类包装任何非托管句柄,可以免去编写终结器的过程。

    1.5K20编辑于 2023-10-17
  • 来自专栏U3D技术分享

    《CLR via C#》笔记:第4部分 核心机制(2)

    (P464 last2) SafeHandle类(P467-P475) 终结的内部工作原理:终结表面上很简单:创建对象,当它被回收时,它的Finalize方法得以调用。

    87510编辑于 2022-09-21
  • 来自专栏痴者工良

    C#多线程(12):线程池

    BindHandle(SafeHandle) 将操作系统句柄绑定到 ThreadPool。

    2.2K20发布于 2021-04-26
领券