IDE: VS 2015
Version: 8.4.96.2023
Target (If relevant): iOS + C#
Description:
iOSTest2.zip (106.4 KB)
public delegate void Action();
public class TestClass {
public void test() {
postDoSth(doSth2);
postDoSth(doSth1);
}
private static void postDoSth(Action action) {
dispatch_async(dispatch_get_main_queue(), action);
}
private void doSth1() {
NSLog("doSth1!!!"); // ok
}
public void doSth2() {
NSLog("doSth2!!!"); // Problem #1: never be called
}
public override void dealloc() {
NSLog("dealloc!!!"); // Problem #2: called before doSth
}
}
[UIApplicationMain, IBObject]
class AppDelegate : IUIApplicationDelegate
{
public UIWindow window { get; set; }
public BOOL application(UIApplication application) didFinishLaunchingWithOptions(NSDictionary launchOptions)
{
window = new UIWindow(UIScreen.mainScreen().bounds);
window.rootViewController = new UIViewController withNibName(null) bundle(null);
window.makeKeyAndVisible();
new TestClass().test();
return true;
}