private async Task <bool> FileExists(string fileAName) { await TaskExHelper.Yield(); var iso = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication(); return(iso.FileExists(fileAName)); }
/// <summary> /// Informs the ThreadPool that there's work to be executed for this scheduler. /// </summary> private async void NotifyThreadPoolOfPendingWork() { #if NETFX_CORE await ThreadPool.RunAsync((_1) => #else await TaskExHelper.Yield(); ThreadPool.QueueUserWorkItem(_ => #endif { // Note that the current thread is now processing work items. // This is necessary to enable inlining of tasks into this thread. _currentThreadIsProcessingItems = true; try { // Process all available items in the queue. while (true) { Task item; lock (_tasks) { // When there are no more items to be processed, // note that we're done processing, and get out. if (_tasks.Count == 0) { --_delegatesQueuedOrRunning; break; } // Get the next item from the queue item = _tasks.First.Value; _tasks.RemoveFirst(); } // Execute the task we pulled out of the queue base.TryExecuteTask(item); } } // We're done processing items on the current thread finally { _currentThreadIsProcessingItems = false; } #if NETFX_CORE }); #else }, null);
private void PropScribe() { GetValueContainer(vm => vm.IsImageMode).GetNewValueObservable().Subscribe(e => { var isimagemode = e.EventArgs; AppSettings.Instance.IsEnableImageMode = isimagemode; }).DisposeWith(this); GetValueContainer(vm => vm.IsLightTheme).GetNewValueObservable().Subscribe(async e => { var islighttheme = e.EventArgs; AppSettings.Instance.CurrentTheme = islighttheme ? ElementTheme.Light : ElementTheme.Dark; App.SetShellDecoration(false); //StageManager.DefaultStage.Frame.RequestedTheme = AppSettings.Instance.CurrentTheme; await TaskExHelper.Yield(); // await StageManager.DefaultStage.Show(new SettingPage_Model()); // ((Page) this.StageManager.CurrentBindingView).RequestedTheme = AppSettings.Instance.CurrentTheme; }).DisposeWith(this); GetValueContainer(vm => vm.AccentColor).GetNewValueObservable().Subscribe(e => { var accentcolor = e.EventArgs; AppSettings.Instance.AccentColor = accentcolor; App.SetShellDecoration(true); // await StageManager.DefaultStage.Show(new SettingPage_Model()); }).DisposeWith(this); //CheckBox点击之后,马上更改设置,以实现实时更新 EventRouter.Instance.GetEventChannel <Object>() .Where(x => x.EventName == "NotyCheckedByEventRouter") .Subscribe( async e => { var item = e.EventData as PostType; if (item != null) { var query = ListPostTypes.Where(listPosttype => listPosttype.IsSelected); AppSettings.Instance.SelectChannelTypes = query.ToList(); } await TaskExHelper.Yield(); } ).DisposeWith(this); }
private void SubscribeCommand() { EventRouter.Instance.GetEventChannel <Object>() .Where(x => x.EventName == "NavToPostDetailByEventRouter") .Subscribe( async e => { await TaskExHelper.Yield(); var item = e.EventData as PostDetail; if (item != null) { await StageManager.DefaultStage.Show(new PostDetailPage_Model(item)); //StageManager.DefaultStage.Frame.Navigate(typeof(PostDetailPage),item); } } ).DisposeWith(this); EventRouter.Instance.GetEventChannel <Object>() .Where(x => x.EventName == "NavToAuthorDetailByEventRouter") .Subscribe( async e => { await TaskExHelper.Yield(); var item = e.EventData as Author; if (item != null) { item.AuthorPostList = new IncrementalLoadingCollection <AuthorPostSource, PostDetail>(item.Id.ToString(), AppStrings.PageSize); await StageManager.DefaultStage.Show(new AuthorPage_Model(item)); //StageManager.DefaultStage.Frame.Navigate(typeof(PostDetailPage),item); } } ).DisposeWith(this); }