本文整理汇总了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 ();
}
示例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;
}