[MonoTouch] SIGSEGV while executing native code
Guido Van Hoecke
guivho at gmail.com
Fri Oct 7 10:14:02 EDT 2011
On Fri, Oct 7, 2011 at 15:51, Nic Wise <nicw at fastchicken.co.nz> wrote:
> My understanding is that a using is basically this:
>
> try {
> //stuff
> } finally {
> theVariable.Dispose();
> }
>
> where as without the using, you are waiting for the GC to collect it,
> which is a non-deterministic thing (might be immediate, might take a
> looooong time, might even be never!)
Indeed, the using statement disposes of the variable, which would occur
before the alert is shown. To free resources asap, I've added a
Dispose() in the 'clicked' delegate of the alert:
button.Clicked += delegate {
var alert = new UIAlertView {Title = "alert", Message = "message" };
alert.AddButton("yes");
alert.AddButton("no");
alert.Clicked += delegate(object sender, UIButtonEventArgs e) {
if (e.ButtonIndex == 0) {
label.Text = "we got a 'yes'";
}
else
{
label.Text = "too bad...";
}
alert.Dispose();
};
alert.Show();
};
Still puzzled why the sigsegv does not occur when starting the installed
app on the simulator: that always works. GC must be runnng a different
schedule then. Similarly, the using clause works fine on the device.
Guido
More information about the MonoTouch
mailing list