[MonoTouch] Issue with CFRunLoop still in v1.1
José Antonio Leal Farias
jalf at sharpgames.net
Fri Oct 2 14:45:26 EDT 2009
Folks,
I'm getting a new error using UIAccelerometer and CFRunLoop together
in v1.1. Check this code:
using MonoTouch.CoreFoundation;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using System;
namespace LoopTest
{
public static class Accelerometer
{
public static void SetupAccelerometer()
{
// Setup the accelerometer
UIAccelerometer.SharedAccelerometer.UpdateInterval = 1/30;
UIAccelerometer.SharedAccelerometer.Acceleration +=
UIAccelerometerSharedAccelerometerAcceleration;
}
private static void UIAccelerometerSharedAccelerometerAcceleration
(object sender, UIAccelerometerEventArgs e)
{
Console.WriteLine("Move");
}
}
[Register ("AppDelegate")]
class Program : UIApplicationDelegate
{
public override void FinishedLaunching (UIApplication app)
{
Accelerometer.SetupAccelerometer();
while (true)
{
while(CFRunLoop.Main.RunInMode(CFRunLoop.ModeDefault,0,true) ==
CFRunLoopExitReason.HandledSource);
Tick();
}
}
void Tick()
{
Console.WriteLine("Tick");
}
static void Main (string [] args)
{
UIApplication.Main (args,null,"AppDelegate");
}
}
}
My application crash all the times. It's a bug or I'm doing something
wrong?
José.
More information about the MonoTouch
mailing list