Exemplo n.º 1
0
	public long test_callback_stored_dynamic_direct() {
		long rounds = defaultRounds;
		TestDynamicDelegate t = (obj, k) => k;
		GCHandle handle = GCHandle.Alloc(t);
		pinvokeTest_setDynamicCallback(Marshal.GetFunctionPointerForDelegate(t));
		for (long i = 0; i < rounds; i++) {
			dummyResult += pinvokeTest_invokeStoredDynamicCallback(GCHandle.ToIntPtr(handle), 1);
		}
		handle.Free();
		return rounds;
	}
Exemplo n.º 2
0
	public PInvokeTests() {
		testStaticDelegate = testStaticCallback;
		testStaticDelegatePtr = Marshal.GetFunctionPointerForDelegate(testStaticDelegate);
		testDynamicDelegate = testDynamicCallback;
		testDynamicDelegatePtr = Marshal.GetFunctionPointerForDelegate(testDynamicDelegate);
	}