Example #1
0
	public long test_callback_given_dynamic() {
		long rounds = defaultRounds;
		for (long i = 0; i < rounds; i++) {
			TestStaticDelegate t = k => k + 10;
			GCHandle handle = GCHandle.Alloc(t);
			dummyResult += pinvokeTest_invokeGivenDynamicCallback(testDynamicDelegatePtr, GCHandle.ToIntPtr(handle), 1);
			handle.Free();
		}
		return rounds;
	}
Example #2
0
	public long test_callback_stored_dynamic() {
		long rounds = defaultRounds;
		TestStaticDelegate t = k => k;
		GCHandle handle = GCHandle.Alloc(t);
		pinvokeTest_setDynamicCallback(testDynamicDelegatePtr);
		for (long i = 0; i < rounds; i++) {
			dummyResult += pinvokeTest_invokeStoredDynamicCallback(GCHandle.ToIntPtr(handle), 1);
		}
		handle.Free();
		return rounds;
	}
Example #3
0
	public PInvokeTests() {
		testStaticDelegate = testStaticCallback;
		testStaticDelegatePtr = Marshal.GetFunctionPointerForDelegate(testStaticDelegate);
		testDynamicDelegate = testDynamicCallback;
		testDynamicDelegatePtr = Marshal.GetFunctionPointerForDelegate(testDynamicDelegate);
	}