當前位置: 首頁>>代碼示例>>C#>>正文


C# NSAutoreleasePool.Dispose方法代碼示例

本文整理匯總了C#中MonoMac.Foundation.NSAutoreleasePool.Dispose方法的典型用法代碼示例。如果您正苦於以下問題:C# NSAutoreleasePool.Dispose方法的具體用法?C# NSAutoreleasePool.Dispose怎麽用?C# NSAutoreleasePool.Dispose使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在MonoMac.Foundation.NSAutoreleasePool的用法示例。


在下文中一共展示了NSAutoreleasePool.Dispose方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: DispatchPendingEvents

 public override void DispatchPendingEvents()
 {
     var until = NSDate.DistantPast;
     var app = NSApplication.SharedApplication;
     var p = new NSAutoreleasePool ();
     while (true) {
         var ev = app.NextEvent (NSEventMask.AnyEvent, until, NSRunLoop.NSDefaultRunLoopMode, true);
         if (ev != null)
             app.SendEvent (ev);
         else
             break;
     }
     p.Dispose ();
 }
開發者ID:nite2006,項目名稱:xwt,代碼行數:14,代碼來源:MacEngine.cs

示例2: FetchDocument

            public string FetchDocument(int page)
            {
                var p = page > 1 ? "&p=" + page : "";
                var uri = string.Format("http://www.dzone.com/links/index.html?type=html{0}", p);

                /* WebClient doesn't work because libc.dylib is not being linked properly by MonoMac
                 * Use Cocoa NSUrlRequest instead as a not-so-pretty-fix
                 *
                var web = new WebClient();
                web.Headers["User-Agent"] = "Mozilla/5.0 (Windows NT 5.1; U; rv:5.0) Gecko/20100101 Firefox/5.0";

                return web.DownloadString(uri);
                */

                var pool = new NSAutoreleasePool();

                NSError error = null;
                NSUrlResponse response = null;
                NSMutableUrlRequest request = new NSMutableUrlRequest(NSUrl.FromString(uri));
                var headerKeys = new NSObject[] {
                    (NSString)"Accept",
                    (NSString)"Accept-Charset",
                    (NSString)"Accept-Encoding",
                    (NSString)"Accept-Language",
                    (NSString)"Cache-Control",
                    (NSString)"Host",
                    (NSString)"User-Agent"
                };
                var headerVals = new NSObject[] {
                    (NSString)"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
                    (NSString)"ISO-8859-1,utf-8;q=0.7,*;q=0.3",
                    (NSString)"deflate",
                    (NSString)"en-US,en;q=0.8",
                    (NSString)"max-age=0",
                    (NSString)"www.dzone.com",
                    (NSString)"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.21 Safari/535.7"
                };
                request.Headers = NSDictionary.FromObjectsAndKeys(headerVals, headerKeys);
                var data = NSUrlConnection.SendSynchronousRequest(request, out response, out error);
                var html = (string)NSString.FromData(data, NSStringEncoding.UTF8);

                pool.Dispose();

                return html;
            }
開發者ID:seanho,項目名稱:DZoneApp,代碼行數:45,代碼來源:DZoneProxy.cs


注:本文中的MonoMac.Foundation.NSAutoreleasePool.Dispose方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。