Forum General

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Monomac issue - please help

Hi, I am timer running in the main controller, and when I try and bring up a context menu on a TableView, the app crashes. If I turn off the timer, no problem and if I dont bring up the content menu, again no problem.

Here is my code:

...
myNSTableView.Menu = new NSMenu();
NSMenuItem mi = new NSMenuItem("menu item 1", myHandler);
myNSTableView.Menu.AddItem(mi);
...

public void myHandler(object Sender, EventArgs e)
{
}
I also have an NSTimer setup to repeat every 200ms

myNSTimer = NSTimer.CreateRepeatingScheduledTimer(new TimeSpan(2000000),delegate {
move an NSSlider
});

NSRunLoop.Main.AddTimer(myNSTimer, NSRunLoopMode.Common);
NSRunLoop.Main.AddTimer(myNSTimer, NSRunLoopMode.EventTracking);

Can anyone give me any pointers to try please?

Posts

  • Although the problem occurred much more with the timer running, this wasn't the problem. I was not storing the MenuItem variables in a class variable or list etc, so they were being garbage collected and cause the lower level objC layer to crash.

Sign In or Register to comment.