diff --git a/src/SharpMetal/Metal/MTLDevice.cs b/src/SharpMetal/Metal/MTLDevice.cs index e9e3237..5813e99 100644 --- a/src/SharpMetal/Metal/MTLDevice.cs +++ b/src/SharpMetal/Metal/MTLDevice.cs @@ -254,6 +254,7 @@ public partial struct MTLDevice: IDisposable { [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void NewLibraryCompletionHandler(IntPtr block, IntPtr library, IntPtr error); + private NewLibraryCompletionHandler _handler; public IntPtr NativePtr; public static implicit operator IntPtr(MTLDevice obj) => obj.NativePtr; @@ -468,8 +469,8 @@ public MTLLibrary NewLibrary(NSString source, MTLCompileOptions options, ref NSE public void NewLibrary(NSString source, MTLCompileOptions options, Action callback) { - NewLibraryCompletionHandler handler = (_, library, error) => callback(new MTLLibrary(library), new NSError(error)); - var block = Block.GetBlockForDelegate(handler); + _handler = (_, library, error) => callback(new MTLLibrary(library), new NSError(error)); + var block = Block.GetBlockForDelegate(_handler); ObjectiveCRuntime.objc_msgSend(NativePtr, sel_newLibraryWithSourceoptionscompletionHandler, source, options, block); } diff --git a/src/SharpMetal/SharpMetal.csproj b/src/SharpMetal/SharpMetal.csproj index 79f51cd..1a17d20 100644 --- a/src/SharpMetal/SharpMetal.csproj +++ b/src/SharpMetal/SharpMetal.csproj @@ -7,7 +7,7 @@ SharpMetal true true - 1.0.0-preview16 + 1.0.0-preview17 Handcrafted Metal bindings for C# https://github.com/IsaacMarovitz/SharpMetal git