本文整理汇总了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;
}
}
});
}
};
}
示例2: CreateWorkerThread
public override Thread CreateWorkerThread(Action act)
{
return new Thread (() => {
using (var pool = new NSAutoreleasePool ())
act ();
});
}
示例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 ();
}
}
}
示例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");
}
示例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");
}
}
示例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 ();
});
}
};
}
示例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
}
示例8: Main
static void Main(string[] args)
{
NSApplication.Init ();
using (var p = new NSAutoreleasePool ()) {
NSApplication.SharedApplication.Delegate = new AppDelegate();
NSApplication.Main(args);
}
}
示例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);
}
}
示例10: Main
static void Main(string[] args)
{
NSApplication.Init();
using (var p = new NSAutoreleasePool ())
{
NSApplication.Main(args);
}
}
示例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;
}
示例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 ();
}
}
示例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;
}
});
}
};
}
示例14: CreatePreferencesView
public override IDesktopPreferencesView CreatePreferencesView()
{
IDesktopPreferencesView view = null;
using (var pool = new NSAutoreleasePool())
{
pool.InvokeOnMainThread(delegate {
view = base.CreatePreferencesView();
});
}
return view;
}
示例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);
}
}
}