void GroupsEnumerator(ALAssetsGroup agroup, ref bool stop)
            {
                if (agroup == null)
                {
                    return;
                }

                //We show photos only. Let's get only them
                agroup.SetAssetsFilter(ALAssetsFilter.AllPhotos);

                //do not add empty album
                if (agroup.Count == 0)
                {
                    return;
                }

                //ALAssetsGroupType.All might have duplicated albums. let's skip the album if we already have it
                if (assetGroups.Any(g => g.PersistentID == agroup.PersistentID))
                {
                    return;
                }

                assetGroups.Add(agroup);

                dispatcher.BeginInvokeOnMainThread(ReloadTableView);
            }
示例#2
0
        public IDisposable Schedule <TState>(TState state, Func <IScheduler, TState, IDisposable> action)
        {
            IDisposable innerDisp = Disposable.Empty;

            theApp.BeginInvokeOnMainThread(new NSAction(() => innerDisp = action(this, state)));

            return(innerDisp);
        }
示例#3
0
        static void EnsureInvokedOnMainThread(Action action)
        {
            if (NSThread.Current.IsMainThread)
            {
                action();
                return;
            }
            if (Invoker == null)
            {
                Invoker = new NSObject();
            }

#if __UNIFIED__
            Invoker.BeginInvokeOnMainThread(action);
#else
            Invoker.BeginInvokeOnMainThread(new NSAction(action));
#endif
        }
示例#4
0
        protected virtual void ExecuteOnMainThread(Action action)
        {
            var obj = new NSObject();

            obj.BeginInvokeOnMainThread(() =>
            {
                action();
                obj.Dispose();
            });
        }
示例#5
0
        public IDisposable Schedule <TState>(TState state, Func <IScheduler, TState, IDisposable> action)
        {
            var innerDisp = new SingleAssignmentDisposable();

            theApp.BeginInvokeOnMainThread(new NSAction(() => {
                if (!innerDisp.IsDisposed)
                {
                    innerDisp.Disposable = action(this, state);
                }
            }));

            return(innerDisp);
        }
示例#6
0
 public static void EnsureRunOnMainThread(Action action)
 {
     if (NSThread.Current.IsMainThread)
     {
         action();
         return;
     }
     if (invoker == null)
     {
         invoker = new NSObject();
     }
     invoker.BeginInvokeOnMainThread(() => action());
 }
示例#7
0
        /// <summary>
        /// Ensures the invoked on main thread.
        /// </summary>
        /// <param name="action">Action to run on main thread.</param>
        public static void EnsureInvokedOnMainThread(Action action)
        {
            if (NSThread.Current.IsMainThread)
            {
                action();
                return;
            }
            if (Invoker == null)
            {
                Invoker = new NSObject();
            }

            Invoker.BeginInvokeOnMainThread(action);
        }
示例#8
0
        public static Task <T> BeginInvokeOnMainThreadAsync <T>(Func <T> a)
        {
            var      tcs       = new TaskCompletionSource <T>();
            NSObject nsViewCon = NSObject.FromObject(MacGui.macGui);

            nsViewCon.BeginInvokeOnMainThread(() => {
                try {
                    var result = a();
                    tcs.SetResult(result);
                }
                catch (Exception ex) { tcs.SetException(ex); }
            });
            return(tcs.Task);
        }
示例#9
0
        public override void Load()
        {
            Action <Action> invoke = x =>
                                     _ns_object.BeginInvokeOnMainThread(new NSAction(() => x()));

            Bind <IContainer>().
            To <NinjectContainer>().
            InSingletonScope();
            Bind <Action <Action> >().
            ToConstant(invoke);

            Bind <IDateTimeModel>().
            To <UtcDateTimeModel>().
            InSingletonScope();
            Bind <IDateTimeView>().
            To <DigitalDateTimeView>().
            InSingletonScope();
        }
示例#10
0
            void GroupsEnumerator(ALAssetsGroup agroup, ref bool stop)
            {
                if (agroup == null)
                {
                    return;
                }

                // added fix for camera albums order
                if (agroup.Name.ToString().ToLower() == "camera roll" && agroup.Type == ALAssetsGroupType.SavedPhotos)
                {
                    AssetGroups.Insert(0, agroup);
                }
                else
                {
                    AssetGroups.Add(agroup);
                }

                _Dispatcher.BeginInvokeOnMainThread(ReloadTableView);
            }
示例#11
0
 public static void QueueForLater(this NSObject nsObject, Action action) =>
 nsObject.BeginInvokeOnMainThread(action);
示例#12
0
 public void Transition(IViewFor fromView, IViewFor toView)
 {
     NSObject.BeginInvokeOnMainThread(() => DoTransition(fromView, toView));
 }
示例#13
0
 public void Invoke(Action action)
 {
     owner.BeginInvokeOnMainThread(new NSAction(action));
 }
示例#14
0
		protected override void ExecuteOnMainThread (Action action)
		{
			var obj = new NSObject ();
			obj.BeginInvokeOnMainThread (() => 
			{
				action ();
				obj.Dispose ();
			});
		}
 public IDisposable Schedule(Action action)
 {
     this.Log().Debug("Scheduling on Runloop");
     theApp.BeginInvokeOnMainThread(new NSAction(action));
     return(Disposable.Empty);
 }
 protected override void InvokeOnUiThreadCore(Action a)
 {
     //NSAction has been replaced with standard action
     invoker.BeginInvokeOnMainThread(a);
 }