On Nov 21, 2012, at 11:00 AM, "Jeremy A. Kolb - ARA/NED" <jk...@ara.com> wrote: > If I wrap the cursor in a "MyCursor" object and forward all the methods on > I'm seeing that Count is being called by the ICursorInvoker: > > 0x1 in MinefieldManagement.Provider.MyCursor.get_Count > 0x9 in Android.Database.ICursorInvoker.n_GetCount > 0xC in object.c279bfc1-6dc5-4f8f-b576-58cb01b20d3d > (System.Reflection.Emit-generated code) > 0x12 in Android.Runtime.JNIEnv.CallObjectMethod > 0xB6 in Android.Content.ContentResolver.Query > 0xD1 in > MinefieldManagement.Overlays.MinefieldOverlay.OnSingleTapConfirmed
It's being called because Java is calling it. Let's reverse that stack trace so we can see timing: 0xD1: MinefieldOverlay.OnSingleTapConfirmed calls ContentResolver.Query() 0xB6: ContentResolver.Query() calls JNIEnv.CallObjectMethod() 0x12: JNIEnv.CallObjectMethod() goes into Dalvik-land... Dalvik-land performs the Java-side ContentResolver.query() call, which is calling back into Managed code? Your C# ContentProvider.Query() is invoked, returns an ICursor implementation to Dalvik-land 0xC: Dalvik-land ContentResolver.query() calls Cursor.getCount() 0x9: Cursor.getCount() is implemented in managed code, so it hits the Android Callable Wrapper ICursorInvoker.n_GetCount() method 0x1: ICursorInvoker.n_GetCount() invokes the ICursor.Count property getter For more information on what ICursorInvoker is doing, see the epic JNI tomb [0, 1]. It's ~all generated code... It would be interesting to see if any other ICursor methods are being invoked in addition to ICursor.Count... My guess is that (1) your query is "big", and (2) Android is trying to copy the entire Cursor contents, and because of (1) the copy takes awhile. To confirm, what value is your ICursor.Count returning, and are the other methods being invoked to grab the data? - Jon [0]: http://docs.xamarin.com/Android/Guides/Advanced_Topics/Java_Integration_Overview/Working_With_JNI [1]: http://docs.xamarin.com/Android/Guides/Advanced_Topics/Java_Integration_Overview/Working_With_JNI#Invoker_Definition _______________________________________________ Monodroid mailing list Monodroid@lists.ximian.com UNSUBSCRIBE INFORMATION: http://lists.ximian.com/mailman/listinfo/monodroid