当前位置: 首页>>代码示例>>C#>>正文


C# Class.release方法代码示例

本文整理汇总了C#中Class.release方法的典型用法代码示例。如果您正苦于以下问题:C# Class.release方法的具体用法?C# Class.release怎么用?C# Class.release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Class的用法示例。


在下文中一共展示了Class.release方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: App

    public App(string nibName)
    {
        NSObject app = (NSObject) new Class("NSApplication").Call("sharedApplication");

        // Load our nib. This will instantiate all of the native objects and wire them together.
        // The C# SimpleLayoutView will be created the first time Objective-C calls one of the
        // methods SimpleLayoutView added or overrode.
        NSObject dict = new Class("NSMutableDictionary").Call("alloc").Call("init").To<NSObject>();
        NSObject key = new Class("NSString").Call("stringWithUTF8String:", Marshal.StringToHGlobalAuto("NSOwner")).To<NSObject>();
        dict.Call("setObject:forKey:", app, key);

        NSObject bundle = new Class("NSBundle").Call("mainBundle").To<NSObject>();

        NSObject nib = new Class("NSString").Call("stringWithUTF8String:", Marshal.StringToHGlobalAuto(nibName)).To<NSObject>();
        sbyte loaded = (sbyte) bundle.Call("loadNibFile:externalNameTable:withZone:", nib, dict, null);
        if (loaded != 1)
            throw new InvalidOperationException("Couldn't load the nib file");

        // We need an NSAutoreleasePool to do Native.Call, but we don't want to have one
        // hanging around while we're in the main event loop because that may hide bugs.
        // So, we'll instantiate a Native instance here and call Invoke later which can
        // be done without an NSAutoreleasePool.
        m_run = new Native(app, new Selector("run"));

        dict.release();
    }
开发者ID:afrog33k,项目名称:mobjc,代码行数:26,代码来源:NSApplication.cs

示例2: Released

    public void Released()
    {
        NSObject pool = new NSObject(NSObject.AllocAndInitInstance("NSAutoreleasePool"));
        long bytes = DoGetMemory();

        for (int j = 1; j < 100; ++j)
        {
            for (int i = 0; i < NumIterations/100; ++i)
            {
                Class klass = new Class("NSNumber");
                klass.release();
            }
            GC.Collect();
        }

        pool.release();
        GC.Collect();
        GC.WaitForPendingFinalizers();

        long delta = DoGetMemory() - bytes;
        if (delta/NumIterations > 4)
            Assert.Fail("Released used {0}K of memory ({1} bytes per iteration)!", delta/1024, delta/NumIterations);
    }
开发者ID:afrog33k,项目名称:mobjc,代码行数:23,代码来源:MemoryTests.cs


注:本文中的Class.release方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。