本文整理汇总了C#中NSAutoreleasePool类的典型用法代码示例。如果您正苦于以下问题:C# NSAutoreleasePool类的具体用法?C# NSAutoreleasePool怎么用?C# NSAutoreleasePool使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NSAutoreleasePool类属于命名空间,在下文中一共展示了NSAutoreleasePool类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RefreshCustomers
public void RefreshCustomers()
{
this.Root.Clear();
this.Root.Add(new Section("") {
new StringElement("Refresh", RefreshCustomers)
});
var json = NSUserDefaults.StandardUserDefaults.StringForKey("customers");
if(string.IsNullOrWhiteSpace(json) == false) {
Customers = JsonSerializer.DeserializeFromString<IEnumerable<Customer>>(json).ToList();
}
if(Customers.Any()) {
var section = new Section("Customers");
foreach(var customer in Customers) {
var desc = string.Format("Customer Name: {0} -- Address: {1}", customer.Name, customer.Address);
section.Add(new StringElement(desc));
}
this.Root.Add(section);
}
using (var pool = new NSAutoreleasePool()) {
pool.BeginInvokeOnMainThread(()=>{
this.ReloadData();
});
}
}
示例2: backgroundWorker_RunWorkerCompleted
// This event handler deals with the results of the
// background operation.
private void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
NSAutoreleasePool pool = new NSAutoreleasePool();
// First, handle the case where an exception was thrown.
if (e.Error != null)
{
// TODO
}
else if (e.Cancelled)
{
this.labelResult.StringValue = "Canceled";
}
else
{
this.labelResult.StringValue = "Fibonacci result for " + this.numberToCompute + " iterations is " + e.Result;
}
this.progressIndicator.DoubleValue = 0.0d;
this.buttonStart.IsEnabled = true;
this.buttonStop.IsEnabled = false;
pool.Release();
}
示例3: FinishedLaunching
// This method is invoked when the application has loaded its UI and its ready to run
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
//HttpDebug.Start ();
MonoMobileApplication.NavigationController = new NavigationController();
MonoMobileApplication.Window = new UIWindow(UIScreen.MainScreen.Bounds);
MonoMobileApplication.Window.AddSubview(MonoMobileApplication.NavigationController.View);
MonoMobileApplication.Window.MakeKeyAndVisible();
MonoMobileApplication.NavigationController.View.Alpha = 0.0f;
#if DEBUG
var thread = new System.Threading.Thread(() =>
{
using (NSAutoreleasePool pool = new NSAutoreleasePool())
{
InvokeOnMainThread(()=> { Startup(); });
}
});
thread.Start();
#else
InvokeOnMainThread(()=> { Startup(); });
#endif
return true;
}
示例4: ShowProgressDialog
public static void ShowProgressDialog(string title, string message, Action action, Action finalize) {
UIAlertView dialog = new UIAlertView(title, message, null, null);
dialog.Show();
_indicatorViewLeftCorner.Hidden = false;
ThreadPool.QueueUserWorkItem(delegate
{
// Run the given Async task
action();
// Run the completion handler on the UI thread and remove the spinner
using (var pool = new NSAutoreleasePool())
{
try
{
pool.InvokeOnMainThread(() =>
{
dialog.DismissWithClickedButtonIndex(0, true);
_indicatorViewLeftCorner.Hidden = true;
finalize();
});
}
catch (Exception ex){
Insights.Report(ex);
}
}
});
}
示例5: Encode
/// <summary>
/// Encodes a frame.
/// </summary>
/// <param name="frame">The frame.</param>
/// <returns></returns>
public override byte[] Encode(AudioBuffer frame)
{
if (_Encoder == null)
{
_Encoder = new CocoaOpusEncoder(ClockRate, Channels, PacketTime);
_Encoder.Quality = 1.0;
_Encoder.Bitrate = 125;
}
using (var pool = new NSAutoreleasePool())
{
GCHandle dataHandle = GCHandle.Alloc(frame.Data, GCHandleType.Pinned);
try
{
IntPtr dataPointer = dataHandle.AddrOfPinnedObject();
using (var buffer = new CocoaOpusBuffer {
Data = NSData.FromBytesNoCopy(dataPointer, (uint)frame.Data.Length, false),
Index = frame.Index,
Length = frame.Length
})
{
using (var encodedFrameData = _Encoder.EncodeBuffer(buffer))
{
return encodedFrameData.ToArray();
}
}
}
finally
{
dataHandle.Free();
}
}
}
示例6: Startup
private void Startup()
{
using (var pool = new NSAutoreleasePool())
{
InvokeOnMainThread(delegate
{
foreach(var view in MonoMobileApplication.Views)
{
var title = MonoMobileApplication.Title;
if (view is IView)
title = ((IView)view).Caption;
var binding = new BindingContext(view, title);
MonoMobileApplication.DialogViewControllers.Add(new DialogViewController(UITableViewStyle.Grouped, binding, true) { Autorotate = true } );
}
_Navigation.ViewControllers = MonoMobileApplication.DialogViewControllers.ToArray();
MonoMobileApplication.CurrentDialogViewController = _Navigation.ViewControllers.First() as DialogViewController;
UIView.BeginAnimations("fadeIn");
UIView.SetAnimationDuration(0.3f);
_Navigation.View.Alpha = 1.0f;
UIView.CommitAnimations();
});
}
}
示例7: DidOutputSampleBuffer
public override void DidOutputSampleBuffer (AVCaptureOutput captureOutput, CMSampleBuffer sampleBuffer, AVCaptureConnection connection)
{
try {
connection.VideoOrientation = AVCaptureVideoOrientation.Portrait;
using (var image = ImageFromSampleBuffer (sampleBuffer)){
if(_CurrentState.didKnock){
KnockCount++;
if(KnockCount==1){
_CurrentState.CountDown = 5;
InvokeOnMainThread (delegate {
_CurrentState.TopLabel.Text = "Knock Again to Post!!";
_CurrentState.BottomLabel.Text = "Knock to Post: 5 sec";
});
}else if(KnockCount==40){
_CurrentState.CountDown = 4;
InvokeOnMainThread (delegate {
_CurrentState.BottomLabel.Text = "Knock to Post: 4 sec";
});
}else if(KnockCount==80){
_CurrentState.CountDown = 3;
InvokeOnMainThread (delegate {
_CurrentState.BottomLabel.Text = "Knock to Post: 3 sec";
});
}else if(KnockCount==120){
_CurrentState.CountDown = 2;
InvokeOnMainThread (delegate {
_CurrentState.BottomLabel.Text = "Knock to Post: 2 sec";
});
}else if(KnockCount==160){
_CurrentState.CountDown = 1;
InvokeOnMainThread (delegate {
_CurrentState.BottomLabel.Text = "Knock to Post: 1 sec";
});
}else if(KnockCount>200){
InvokeOnMainThread (delegate {
_CurrentState.TopLabel.Text = "Follow @JoesDoor on Twitter";
_CurrentState.BottomLabel.Text = "Knock to take a photo";
});
KnockCount=0;
_CurrentState.CountDown = 0;
_CurrentState.didKnock=false;
}
}else{
InvokeOnMainThread(delegate {
using (var pool = new NSAutoreleasePool ()) {
_CurrentState.DisplayImageView.Image = image;
}
});
}
}
sampleBuffer.Dispose ();
} catch (Exception e){
Console.WriteLine (e);
}
}
示例8: Call
public override ICallControl Call(string phoneNumber, CallType type)
{
if (CallType.Voice.Equals (type)) {
using (var pool = new NSAutoreleasePool ()) {
StringBuilder filteredPhoneNumber = new StringBuilder();
if (phoneNumber!=null && phoneNumber.Length>0) {
foreach (char c in phoneNumber) {
if (Char.IsNumber(c) || c == '+' || c == '-' || c == '.') {
filteredPhoneNumber.Append(c);
}
}
}
String textURI = "tel:" + filteredPhoneNumber.ToString();
var thread = new Thread (InitiateCall);
thread.Start (textURI);
}
;
} else {
INotification notificationService = (INotification)IPhoneServiceLocator.GetInstance ().GetService ("notify");
if (notificationService != null) {
notificationService.StartNotifyAlert ("Phone Alert", "The requested call type is not enabled or supported on this device.", "OK");
}
}
return null;
}
示例9: Game
public Game(float width, float height)
: base(width, height)
{
using (NSAutoreleasePool pool = new NSAutoreleasePool ())
{
AddChild (SPImage.ImageWithContentsOfFile ("Default.png"));
mMainMenu = new SPSprite();
AddChild (mMainMenu);
mMainMenu.AddChild (SPImage.ImageWithContentsOfFile ("logo.png"));
SPTexture sceneButtonTexture = SPTexture.TextureWithContentsOfFile ("button_big.png");
atlasButton = SPButton.ButtonWithUpState (sceneButtonTexture, "Texture Atlas");
atlasButton.AddEventListener (onAtlasButtonTriggered, SPEvents.ButtonTriggered);
addSceneButton (atlasButton);
SPTexture backButtonTexture = SPTexture.TextureWithContentsOfFile ("button_back.png");
mBackButton = new SPButton (backButtonTexture, "back");
mBackButton.Visible = false;
mBackButton.X = (int)(Stage.Width - mBackButton.Width) / 2;
mBackButton.Y = Stage.Height - mBackButton.Height + 1;
mBackButton.AddEventListener (onBackButtonTriggered, SPEvents.ButtonTriggered);
AddChild (mBackButton);
// SPJuggler jug = this.Stage.Juggler;
// jug.DelayInvocationAtTarget (this, 5.0).PerformSelector (new Selector ("onAtlasButtonTriggered:"), null, 0);
}
}
示例10: DoSomething
// Uncomment to demonstrate UIActiviyIndicatorView
// void HandleShowActivityButtonTouchUpInside (object sender, EventArgs e)
// {
// _activityView = new UIActivityIndicatorView ();
//
// _activityView.Frame = new RectangleF (0, 0, 50, 50);
// _activityView.Center = View.Center;
//
// _activityView.ActivityIndicatorViewStyle = UIActivityIndicatorViewStyle.WhiteLarge;
// View.AddSubview (_activityView);
// _activityView.StartAnimating ();
//
// Thread t = new Thread (DoSomething);
// t.Start ();
// }
void DoSomething ()
{
Thread.Sleep (3000);
using (var pool = new NSAutoreleasePool ()) {
this.InvokeOnMainThread (delegate { _activityView.StopAnimating (); });
}
}
示例11: Run
private static void Run()
{
NSAutoreleasePool pool = new NSAutoreleasePool ();
Console.WriteLine ("Hello World !!!");
pool.Release ();
}
示例12: GetObjectData
/// <summary>
/// Populates a <see cref="T:System.Runtime.Serialization.SerializationInfo"/> with the data needed to serialize the target object.
/// </summary>
/// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"/> to populate with data.</param>
/// <param name="context">The destination (see <see cref="T:System.Runtime.Serialization.StreamingContext"/>) for this serialization.</param>
/// <exception cref="T:System.Security.SecurityException">
/// The caller does not have the required permission.
/// </exception>
public void GetObjectData (SerializationInfo info, StreamingContext context)
{
// As pool are scoped, it does not hurt if we create ours during the method call.
using (NSAutoreleasePool pool = new NSAutoreleasePool()) {
NSData data = this.TIFFRepresentation;
info.AddValue ("Data", data.GetBuffer (), typeof(byte[]));
}
}
示例13: HideSearchingView
public void HideSearchingView()
{
using(var pool = new NSAutoreleasePool()) {
pool.BeginInvokeOnMainThread(() => {
IsSearching = false;
_SearchingView.Hidden = true;
});
}
}
示例14: Main
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main (string[] args)
{
NSApplication.Init ();
using (var p = new NSAutoreleasePool ()) {
NSApplication.SharedApplication.Delegate = new AppDelegate ();
NSApplication.Main (args);
}
}
示例15: SetRequestInterval
public override bool SetRequestInterval(double intervalInSeconds)
{
using (var pool = new NSAutoreleasePool ()) {
Thread thread = new Thread (SetRequestIntervalThread);
thread.Priority = ThreadPriority.AboveNormal;
thread.Start ((object)intervalInSeconds);
}
return true;
}