[MonoTouch] SIGSEGV while executing native code

Nic Wise nicw at fastchicken.co.nz
Fri Oct 7 09:51:10 EDT 2011


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!)

Which would explain what you are seeing.

On Fri, Oct 7, 2011 at 14:39, Guido Van Hoecke <guivho at gmail.com> wrote:
> On Fri, Oct 7, 2011 at 13:11, steott at gmail.com <steott at gmail.com> wrote:
>> Hi Guido, if you just try to remove the using block for the alert?
>> I had the same problem and it was solved in this way.
> Well, removing the 'using' clause fixed the problem:
>
> 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.Show();
> };
>
> I must confess that I do not really see the difference with the original:
>
> button.Clicked += delegate {
>    using (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.Show();
>    }
> };
>
> Isn't the variable 'alert' a local temporary variable in both cases?
>
> Well, anyway, my problem is fixed.
>
> Thanx for the help,
>
>
> Guido.
> _______________________________________________
> MonoTouch mailing list
> MonoTouch at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/monotouch
>



-- 
Nic Wise
t.  +44 7788 592 806 | @fastchicken | http://www.linkedin.com/in/nicwise
b. http://www.fastchicken.co.nz/

mobileAgent (for FreeAgent): get your accounts in your pocket.
http://goo.gl/IuBU
Trip Wallet: Keep track of your budget on the go: http://goo.gl/ePhKa
London Bike App: Find the nearest Boris Bike, and get riding! http://goo.gl/Icp2


More information about the MonoTouch mailing list