Question...
How do I override the normal run loop in UIApplication.Main and use my own
run loop? From the docs I've read, I thought I could do something like
this...
this.InvokeOnMainThread (delegate {
while (needHighResolutionTouches) {
while
(CFRunLoop.Current.RunInMode(CFRunLoop.CFDefaultRunLoopMode,0.04,false)
== CFRunLoopExitReason.HandledSource); }});
However, this seems not to work.. it just hangs my app.. How do I make a
custom run loop while still handling a UIApplication.Main() style init?
--------------------
Background....
I'm writing a drawing app in MonoTouch. During canvas drawing, touch events
on slower devices (like ipad 1) are too infrequent and create jagged lines.
>From some research, it looks like one solution to this is to call
CFRunLoopRunInMode<https://developer.apple.com/library/mac/#documentation/CoreFoundation/Reference/CFRunLoopRef/Reference/reference.html>with
different paramaters, increasing the amount of time the main run loop
dedicates to touch sampling.
SInt32 CFRunLoopRunInMode (
CFStringRef
<https://developer.apple.com/library/mac/documentation/CoreFoundation/Reference/CFStringRef/Reference/reference.html#//apple_ref/doc/c_ref/CFStringRef>
mode,
CFTimeInterval
<https://developer.apple.com/library/mac/documentation/CoreFoundation/Reference/CFTimeUtils/Reference/reference.html#//apple_ref/doc/c_ref/CFTimeInterval>
seconds,
Boolean returnAfterSourceHandled
);
For example, Cocoa2d has the following code as part of it's custom run
loop<http://cocos2d-iphone.googlecode.com/svn-history/r1309/trunk/cocos2d/Director.m>,
where the first case is for when you need high resolution touch events..
#if DIRECTOR_FASTDIRECTOR_FAST_EVENTS
while( CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.004f, FALSE)
==
kCFRunLoopRunHandledSource);
#else
while(CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, TRUE) ==
kCFRunLoopRunHandledSource);
#endif
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch