aboutsummaryrefslogtreecommitdiffstatsci
path: root/vke/src/ExtensionMethods.cs
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2019-04-05 14:13:20 +0200
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2019-04-05 14:13:20 +0200
commit04d94de392b6e5ca4f82acc233df7b3f97abca36 (patch)
tree27df9645ea97cf36c99cb4f8ed5f347cc00cb458 /vke/src/ExtensionMethods.cs
parent7d305b07ccaeb2a8cd342e3395db46f2f8fffade (diff)
Activable pattern wip
Diffstat (limited to 'vke/src/ExtensionMethods.cs')
-rw-r--r--vke/src/ExtensionMethods.cs17
1 files changed, 16 insertions, 1 deletions
diff --git a/vke/src/ExtensionMethods.cs b/vke/src/ExtensionMethods.cs
index 1cf01cd..620c379 100644
--- a/vke/src/ExtensionMethods.cs
+++ b/vke/src/ExtensionMethods.cs
@@ -62,6 +62,21 @@ namespace VKE {
handles[obj].Free ();
handles.Remove (obj);
}
-
+ public static IntPtr Pin<T> (this List<T> obj) {
+ if (handles.ContainsKey (obj))
+ Debug.WriteLine ("Pinning already pinned object: {0}", obj);
+
+ GCHandle hnd = GCHandle.Alloc (obj.ToArray(), GCHandleType.Pinned);
+ handles.Add (obj, hnd);
+ return hnd.AddrOfPinnedObject ();
+ }
+ //public static void Unpin<T> (this List<T> obj) {
+ // if (!handles.ContainsKey (obj)) {
+ // Debug.WriteLine ("Trying to unpin {0}, but object has not been pinned.", obj);
+ // return;
+ // }
+ // handles[obj].Free ();
+ // handles.Remove (obj);
+ //}
}
}