Dispose() protected method

protected Dispose ( bool disposing ) : void
disposing bool
return void
Exemplo n.º 1
0
 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 ();
 }
Exemplo n.º 2
0
            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;
            }