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


C# Foundation.NSAutoreleasePool類代碼示例

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


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

示例1: StatusIcon

        public StatusIcon() : base() {
            using (var a = new NSAutoreleasePool()) {
                this.CreateAnimationFrames();

                this.status_item = NSStatusBar.SystemStatusBar.CreateStatusItem(28);
                this.status_item.HighlightMode = true;
                this.status_item.Image = this.animation_frames[0];

                this.status_item.Image               = this.animation_frames[0];
                this.status_item.Image.Size          = new SizeF(16, 16);
                this.status_item.AlternateImage      = this.animation_frames_active[0];
                this.status_item.AlternateImage.Size = new SizeF(16, 16);

                this.CreateMenu();
            }

            this.Controller.UpdateIconEvent += delegate(int icon_frame) {
                using (var a = new NSAutoreleasePool()) {
                    BeginInvokeOnMainThread(delegate {
                        if (icon_frame > -1) {
                            this.status_item.Image               = this.animation_frames[icon_frame];
                            this.status_item.Image.Size          = new SizeF(16, 16);
                            this.status_item.AlternateImage      = this.animation_frames_active[icon_frame];
                            this.status_item.AlternateImage.Size = new SizeF(16, 16);

                        } else {
                            this.status_item.Image               = this.error_image;
                            this.status_item.AlternateImage      = this.error_image_active;
                            this.status_item.Image.Size          = new SizeF(16, 16);
                            this.status_item.AlternateImage.Size = new SizeF(16, 16);
                        }
                    });
                }
            };

            this.Controller.UpdateMenuEvent += delegate {
                using (var a = new NSAutoreleasePool()) {
                    this.InvokeOnMainThread(() => this.CreateMenu());
                }
            };

            this.Controller.UpdateSuspendSyncFolderEvent += delegate(string reponame) {
                using (var a = new NSAutoreleasePool()){
                    this.InvokeOnMainThread(delegate {
                        foreach (var repoItem in this.repoItems) {
                            if (repoItem.RepositoryName == reponame) {
                                foreach (var repo in Program.Controller.Repositories) {
                                    if (repo.Name.Equals(reponame)) {
                                        repoItem.Status = repo.Status;
                                        break;
                                    }
                                }

                                break;
                            }
                        }
                    });
                }
            };
        }
開發者ID:OpenDataSpace,項目名稱:CmisSync,代碼行數:60,代碼來源:StatusIcon.cs

示例2: CreateWorkerThread

 public override Thread CreateWorkerThread(Action act)
 {
     return new Thread (() => {
         using (var pool = new NSAutoreleasePool ())
             act ();
     });
 }
開發者ID:kelegorm,項目名稱:awareness,代碼行數:7,代碼來源:MacPlatform.cs

示例3: SparkleUI

        public SparkleUI()
        {
            // Use translations
            Catalog.Init ("sparkleshare",
                Path.Combine (NSBundle.MainBundle.ResourcePath, "Translations"));

            using (NSAutoreleasePool pool = new NSAutoreleasePool ()) {

                // Needed for Growl
                GrowlApplicationBridge.WeakDelegate = this;
                GrowlApplicationBridge.Delegate = new SparkleGrowlDelegate ();

                NSApplication.SharedApplication.ApplicationIconImage
                    = NSImage.ImageNamed ("sparkleshare.icns");

                SetFolderIcon ();

                Font = NSFontManager.SharedFontManager.FontWithFamily
                    ("Lucida Grande", NSFontTraitMask.Condensed, 0, 13);

                BoldFont = NSFontManager.SharedFontManager.FontWithFamily
                    ("Lucida Grande", NSFontTraitMask.Bold, 0, 13);

                StatusIcon = new SparkleStatusIcon ();
                Bubbles = new SparkleBubbles ();

                if (Program.Controller.FirstRun) {
                    Setup = new SparkleSetup ();
                    Setup.Controller.ShowSetupPage ();
                }
            }
        }
開發者ID:budi-khoirudin,項目名稱:SparkleShare,代碼行數:32,代碼來源:SparkleUI.cs

示例4: SparkleController

        public SparkleController()
            : base()
        {
            using (var a = new NSAutoreleasePool ())
            {
                string content_path =
                    Directory.GetParent (System.AppDomain.CurrentDomain.BaseDirectory).ToString ();

                string app_path   = Directory.GetParent (content_path).ToString ();
                string growl_path = Path.Combine (app_path, "Frameworks", "Growl.framework", "Growl");

                // Needed for Growl
                Dlfcn.dlopen (growl_path, 0);
                NSApplication.Init ();
            }

            // Let's use the bundled git first
            SparkleLib.Git.SparkleGit.Path =
                Path.Combine (NSBundle.MainBundle.ResourcePath,
                    "git", "libexec", "git-core", "git");

            SparkleLib.Git.SparkleGit.ExecPath =
                Path.Combine (NSBundle.MainBundle.ResourcePath,
                    "git", "libexec", "git-core");
        }
開發者ID:nicolaslazartekaqui,項目名稱:SparkleShare,代碼行數:25,代碼來源:SparkleController.cs

示例5: BackgroundWorkerThread

		}//if
        
		void BackgroundWorkerThread ()
		{
			// Create an Autorelease Pool or we will leak objects.
			using (var pool = new NSAutoreleasePool()) {
				// Create a loop that will add 5 new components with
				// a 2 second pause between additions
				Console.WriteLine ("Before component load");
				for (int x = 1; x <= 5; x++) {

					Console.WriteLine ("Before add");

					// Make sure we invoke this on the Main Thread or OpenGL will throw an error
					MonoMac.AppKit.NSApplication.SharedApplication.BeginInvokeOnMainThread (delegate {
						Components.Add (new TestTexture (this));
					});
					Console.WriteLine ("After add");
					// Sleep for 2 seconds between each component addition
					Thread.Sleep (2000);

				}
				Console.WriteLine ("After component load");

			}

		}
開發者ID:Nailz,項目名稱:MonoGame-Samples,代碼行數:27,代碼來源:Game1.cs

示例6: SparkleSetup

        public SparkleSetup()
            : base()
        {
            SparkleSetupController.HideWindowEvent += delegate {
                NSRunLoop.Main.BeginInvokeOnMainThread (delegate {
                    PerformClose (this);
                });
            };

            SparkleSetupController.ShowWindowEvent += delegate {
                NSRunLoop.Main.BeginInvokeOnMainThread (delegate {
                    OrderFrontRegardless ();
                });
            };

            SparkleSetupController.ChangePageEvent += delegate (Controller.PageType type, string [] warnings) {
                using (var a = new NSAutoreleasePool ())
                {
                    NSRunLoop.Main.BeginInvokeOnMainThread (delegate {
                        Reset ();
                        ShowPage (type, warnings);
                        ShowAll ();
                    });
                }
            };
        }
開發者ID:greenqloud,項目名稱:qloudsync,代碼行數:26,代碼來源:SparkleSetup.cs

示例7: Main

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main(string[] args)
        {
            Debug.WriteLine("[Dark Havoc] Starting up...");

#if !MONOMAC
            // Add application exit event hook.
            AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit);

            // Create game instance.
            gameInstance = new DarkHavocGame();

            // Run game.
            gameInstance.Run();

#else
			Debug.WriteLine("[Dark Havoc] Initializing Mac OS X Subsystem...");

			NSApplication.Init();

			using (var p = new NSAutoreleasePool()) 
			{
				NSApplication.SharedApplication.Delegate = new AppDelegate();
				NSApplication.Main(args);
			}
#endif
        }
開發者ID:JoshuaKennedy,項目名稱:DarkHavoc,代碼行數:29,代碼來源:Program.cs

示例8: Main

 static void Main(string[] args)
 {
     NSApplication.Init ();
     using (var p = new NSAutoreleasePool ()) {
         NSApplication.SharedApplication.Delegate = new AppDelegate();
         NSApplication.Main(args);
     }
 }
開發者ID:GlennGeenen,項目名稱:Mono-Chess,代碼行數:8,代碼來源:Main.cs

示例9: SetFolderIcon

 public void SetFolderIcon ()
 {
     using (var a = new NSAutoreleasePool ())
     {
         NSImage folder_icon = NSImage.ImageNamed ("cmissync-folder.icns");
         NSWorkspace.SharedWorkspace.SetIconforFile (folder_icon, Program.Controller.FoldersPath, 0);
     }
 }
開發者ID:keithwharrison,項目名稱:Oris4Sync,代碼行數:8,代碼來源:UI.cs

示例10: Main

		static void Main(string[] args)
        {
            NSApplication.Init();
            using (var p = new NSAutoreleasePool ())
            {
                NSApplication.Main(args);
            }
		}
開發者ID:pascalfr,項目名稱:MPfm,代碼行數:8,代碼來源:Main.cs

示例11: GetCredentials

		public ICredentials GetCredentials (Uri uri, IWebProxy proxy, CredentialType credentialType, ICredentials existingCredentials, bool retrying)
		{
			bool result = false;
			DispatchService.GuiSyncDispatch (() => {
				using (var ns = new NSAutoreleasePool ()) {
					var message = string.Format ("{0} needs {1} credentials to access {2}.", BrandingService.ApplicationName, 
					                             credentialType == CredentialType.ProxyCredentials ? "proxy" : "request", uri.Host);

					NSAlert alert = NSAlert.WithMessage ("Credentials Required", "OK", "Cancel", null, message);
					alert.Icon = NSApplication.SharedApplication.ApplicationIconImage;

					NSView view = new NSView (new RectangleF (0, 0, 313, 91));

					var creds = Utility.GetCredentialsForUriFromICredentials (uri, existingCredentials);

					var usernameLabel = new NSTextField (new RectangleF (17, 55, 71, 17)) {
						Identifier = "usernameLabel",
						StringValue = "Username:",
						Alignment = NSTextAlignment.Right,
						Editable = false,
						Bordered = false,
						DrawsBackground = false,
						Bezeled = false,
						Selectable = false,
					};
					view.AddSubview (usernameLabel);

					var usernameInput = new NSTextField (new RectangleF (93, 52, 200, 22));
					usernameInput.StringValue = creds != null ? creds.UserName : string.Empty;
					view.AddSubview (usernameInput);

					var passwordLabel = new NSTextField (new RectangleF (22, 23, 66, 17)) {
						StringValue = "Password:",
						Alignment = NSTextAlignment.Right,
						Editable = false,
						Bordered = false,
						DrawsBackground = false,
						Bezeled = false,
						Selectable = false,
					};
					view.AddSubview (passwordLabel);

					var passwordInput = new NSSecureTextField (new RectangleF (93, 20, 200, 22));
					passwordInput.StringValue = creds != null ? creds.Password : string.Empty;
					view.AddSubview (passwordInput);

					alert.AccessoryView = view;
					result = alert.RunModal () == 1;

					username = usernameInput.StringValue;
					password = passwordInput.StringValue;
				}
			});

			return result ? new NetworkCredential (username, password) : null;
		}
開發者ID:fedorw,項目名稱:monodevelop,代碼行數:56,代碼來源:MacProxyCredentialProvider.cs

示例12: SparkleUI

        public SparkleUI()
        {
            using (var a = new NSAutoreleasePool ()) {
                NSApplication.SharedApplication.ApplicationIconImage = NSImage.ImageNamed ("qloudsync-app.icns");
                Setup = new SparkleSetup ();
                About = new AboutWindow ();
                StatusIcon = new IconController ();

            }
        }
開發者ID:greenqloud,項目名稱:qloudsync,代碼行數:10,代碼來源:SparkleUI.cs

示例13: Initialize

        // Shared initialization code
        void Initialize ()
        {
            Controller = new SetupController ();

            Controller.ShowWindowEvent += delegate {
                InvokeOnMainThread (delegate {
                    Window.OrderFrontRegardless();
                });
            };

            Controller.HideWindowEvent += delegate {
                InvokeOnMainThread (delegate {
                    Window.PerformClose (this);
                });
            };

            Controller.ChangePageEvent += delegate (PageType type) {
                using (var a = new NSAutoreleasePool ())
                {
                    InvokeOnMainThread (delegate {
                        if (!IsWindowLoaded) {
                            LoadWindow();
                        }
                        switch (type)
                        {
                        case PageType.Setup:
                            ShowWelcomePage();
                            break;
                        case PageType.Tutorial:
                            ShowTutorialPage();
                            break;
                        case PageType.Add1:
                            ShowLoginPage();
                            break;
                        case PageType.Add2:
                            ShowRepoSelectPage();
                            break;
                        case PageType.Customize:
                            ShowCustomizePage();
                            break;
                        // case PageType.Syncing:
                        //    ShowSyncingPage();
                        //    break;
                        case PageType.Finished:
                            ShowFinishedPage();
                            break;
                        case PageType.Settings:
                            ShowSettingsPage();
                            break;
                        }
                    });
                }
            };
        }
開發者ID:emrul,項目名稱:CmisSync,代碼行數:55,代碼來源:SetupWizardController.cs

示例14: CreatePreferencesView

 public override IDesktopPreferencesView CreatePreferencesView()
 {
     IDesktopPreferencesView view = null;
     using (var pool = new NSAutoreleasePool())
     {
         pool.InvokeOnMainThread(delegate {
             view = base.CreatePreferencesView();
         });
     }
     return view;
 }
開發者ID:pascalfr,項目名稱:MPfm,代碼行數:11,代碼來源:MacNavigationManager.cs

示例15: StorageDeviceHelper

		static StorageDeviceHelper ()
		{
			if (fileManager == null) {

				// Because this will run in a background thread we need to wrap it
				using (var p = new NSAutoreleasePool ()) {
					fileManager = NSFileManager.DefaultManager;
					attributes = fileManager.GetFileSystemAttributes(path, out error);
				}					
			}
		}
開發者ID:Zodge,項目名稱:MonoGame,代碼行數:11,代碼來源:StorageDeviceHelper.cs


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