protected override void OnLoadCompleted(object sender, AsyncCompletedEventArgs e) { IsRefreshing = false; Refreshed?.Invoke(this, EventArgs.Empty); var loader = CollectionViewLoader as RemoteCollectionViewLoader; var operation = loader.CurrentOperation as ILoadOperation; if (operation.Error != null || operation.IsCanceled) { return; } var result = operation.Result.Cast <object>(); var source = CollectionView.SourceCollection as List <object>; source.Clear(); foreach (var item in result) { source.Add(item); } SetTotalItemCount(operation.TotalCount); base.OnLoadCompleted(sender, e); }
public async Task RefreshList(SwipeRefreshLayout sender) { var addedElements = 0; var startCount = 0; try { await Task.Run(async() => { var client = new ApiClient(); var list = await client.GetStrikeListAsync(); startCount = StrikeList.Count; addedElements = CompareLists.Compare(Madapter.StrikeList, list.Strike); }); } catch (Exception) { return; } sender.Refreshing = false; if (addedElements > 0) { Madapter.NotifyItemRangeInserted(0, addedElements); } MlayoutManager.ScrollToPosition(0); Refreshed.Invoke(Refreshed, 0); }
public async Task Refresh() { if (IsBusy) { return; } IsBusy = true; try { await Refreshed?.Invoke(this, index); ItemsSource.CollectionChanged -= ItemsSource_CollectionChanged; ItemsSource.CollectionChanged += ItemsSource_CollectionChanged; if (ItemsSource == null || ItemsSource.Count <= 0) { return; } await PopulateView(); }catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("Refresh Error", ex.Message, "OK"); } finally { IsBusy = false; } }
/// <summary> /// TODO /// </summary> /// <returns></returns> public async Task Reload() { try { await ReLoadProducts(); await ReLoadOrders(); await ReLoadCategories(); if (!string.IsNullOrEmpty(ConnectedDogeAccountAddress)) { await CheckDogePayments(); } else if (!string.IsNullOrEmpty(ConnectedNeblioAccountAddress)) { await CheckNeblioPayments(); } if (AllowDispatchNFTOrders) { await CheckReceivedPaymentsToDispatch(); await SendOrdersToCustomer(); } Refreshed?.Invoke(this, null); } catch (Exception ex) { Console.WriteLine("Cannot process standard cycle. " + ex.Message); } }
public MainViewModel(Settings settings, LanguageManager languageManager, HotKeyManager hotKeyManager, IPreviewWindow previewWindow, IDialogService dialogService, RecordingModel recordingModel, MainModel mainModel) : base(settings, languageManager) { _dialogService = dialogService; ShowPreviewCommand = new DelegateCommand(previewWindow.Show); #region Commands RefreshCommand = recordingModel .ObserveProperty(model => model.RecorderState) .Select(recorderState => recorderState == RecorderState.NotRecording) .ToReactiveCommand() .WithSubscribe(() => { mainModel.Refresh(); Refreshed?.Invoke(); }); OpenOutputFolderCommand = new DelegateCommand(OpenOutputFolder); SelectOutputFolderCommand = new DelegateCommand(SelectOutputFolder); ResetFFmpegFolderCommand = new DelegateCommand(() => settings.FFmpeg.FolderPath = ""); TrayLeftClickCommand = new DelegateCommand(() => hotKeyManager.FakeHotKey(settings.Tray.LeftClickAction)); #endregion }
public void Refresh() { if (Current != null) { Refreshed?.Invoke(this, EventArgs.Empty); } }
public void Recalculate() { UnitPriceMethod method; double craftYield = 0; if (Character != null) { UnitCost = ItemCostCalculator.GetUnitPrice(Item, Character, out method); CraftCost = Item.MadeFrom.Any() ? CraftCostCalculator.CostToCraft(Item, Character, out craftYield) : 0; } else { UnitCost = ItemCostCalculator.GetUnitPrice(Item, out method); CraftCost = Item.MadeFrom.Any() ? CraftCostCalculator.CostToCraft(Item, out craftYield) : 0; } CraftYield = craftYield; BestMethod = method; MarketPrice = MarketPriceCalculator.GetMarketPrice(Item); NetRevenue = MarketPriceCalculator.GetNetSaleRevenue(Item); Profit = NetRevenue - UnitCost; MarketCraftDifference = MarketPrice - CraftCost; Refreshed?.Invoke(this, new EventArgs()); }
private void RefreshThreadWorker() { var lastTime = DateTime.Now; var lastProcessorTime = _process.TotalProcessorTime; while (_process != null && !_process.HasExited) { // Update the process _process.Refresh(); // Update CPU usage var currentTime = DateTime.Now; var currentProcessorTime = _process.TotalProcessorTime; _cpuUsage = (float)((currentProcessorTime.TotalMilliseconds - lastProcessorTime.TotalMilliseconds) / currentTime.Subtract(lastTime).TotalMilliseconds / Environment.ProcessorCount) * 100f; Refreshed?.Invoke(); Thread.Sleep(1000 / RefreshFrequency); } // Reset vars Fps = 0; State = string.Empty; PlayerCount = 0; PlayerLimit = 0; Map = string.Empty; Mode = string.Empty; Refreshed?.Invoke(); }
public MainViewModel(Settings Settings, LanguageManager LanguageManager, HotKeyManager HotKeyManager, IPreviewWindow PreviewWindow, IDialogService DialogService, RecordingModel RecordingModel, MainModel MainModel) : base(Settings, LanguageManager) { _dialogService = DialogService; ShowPreviewCommand = new DelegateCommand(PreviewWindow.Show); #region Commands RefreshCommand = RecordingModel .ObserveProperty(M => M.RecorderState) .Select(M => M == RecorderState.NotRecording) .ToReactiveCommand() .WithSubscribe(() => { MainModel.Refresh(); Refreshed?.Invoke(); }); OpenOutputFolderCommand = new DelegateCommand(OpenOutputFolder); SelectOutputFolderCommand = new DelegateCommand(SelectOutputFolder); ResetFFmpegFolderCommand = new DelegateCommand(() => Settings.FFmpeg.FolderPath = ""); TrayLeftClickCommand = new DelegateCommand(() => HotKeyManager.FakeHotkey(Settings.Tray.LeftClickAction)); #endregion }
public override void ApplyFilter() { View?.Refresh(); if (SelectedItem == null) { View.MoveCurrentToFirst(); } Refreshed?.Invoke(); }
/// <summary> /// Manually updates the collection's data. /// </summary> /// <param name="force">Indicates that the refresh should ignore the value in <see cref="TrelloConfiguration.RefreshThrottle"/> and make the call to the API.</param> /// <param name="ct">(Optional) A cancellation token for async processing.</param> public Task Refresh(bool force = false, CancellationToken ct = default) { if (Auth == TrelloAuthorization.Null) { return(Task.CompletedTask); } Refreshed?.Invoke(this, new EventArgs()); return(PerformRefresh(force, ct)); }
public void Reload() { Orders.Load(); Machines.Load(); Tasks.Load(); Customers.Load(); Properties.Load(); Rules.Load(); Refreshed?.Invoke(new RefreshEventArgs(this)); }
void OnRefresh() { #region Video Codec var lastVideoCodecName = VideoViewModel.SelectedVideoWriter?.ToString(); VideoViewModel.RefreshCodecs(); var matchingVideoCodec = VideoViewModel.AvailableVideoWriters.FirstOrDefault(M => M.ToString() == lastVideoCodecName); if (matchingVideoCodec != null) { VideoViewModel.SelectedVideoWriter = matchingVideoCodec; } #endregion #region Audio var lastMicNames = AudioSource.AvailableRecordingSources .Where(M => M.Active) .Select(M => M.Name) .ToArray(); var lastSpeakerNames = AudioSource.AvailableLoopbackSources .Where(M => M.Active) .Select(M => M.Name) .ToArray(); AudioSource.Refresh(); foreach (var source in AudioSource.AvailableRecordingSources) { source.Active = lastMicNames.Contains(source.Name); } foreach (var source in AudioSource.AvailableLoopbackSources) { source.Active = lastSpeakerNames.Contains(source.Name); } #endregion #region Webcam var lastWebcamName = WebCamProvider.SelectedCam?.Name; WebCamProvider.Refresh(); var matchingWebcam = WebCamProvider.AvailableCams.FirstOrDefault(M => M.Name == lastWebcamName); if (matchingWebcam != null) { WebCamProvider.SelectedCam = matchingWebcam; } #endregion Refreshed?.Invoke(); }
private void _bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Cancelled) { Notifier.Pop("Can't reach the player list!"); return; } Table = (DataSet.PlayersDataTable)e.Result; Refreshed?.Invoke(this, e); }
public MainViewModel(Settings Settings, ILocalizationProvider Loc, HotKeyManager HotKeyManager, IPreviewWindow PreviewWindow, IDialogService DialogService, RecordingModel RecordingModel, IEnumerable <IRefreshable> Refreshables, IFFmpegViewsProvider FFmpegViewsProvider, RememberByName RememberByName) : base(Settings, Loc) { _dialogService = DialogService; _rememberByName = RememberByName; OutFolderDisplay = Settings .ObserveProperty(M => M.OutPath) .Select(M => Settings.GetOutputPath()) .ToReadOnlyReactivePropertySlim(); ShowPreviewCommand = new ReactiveCommand() .WithSubscribe(PreviewWindow.Show); SelectFFmpegFolderCommand = new ReactiveCommand() .WithSubscribe(FFmpegViewsProvider.PickFolder); #region Commands RefreshCommand = RecordingModel .ObserveProperty(M => M.RecorderState) .Select(M => M == RecorderState.NotRecording) .ToReactiveCommand() .WithSubscribe(() => { foreach (var refreshable in Refreshables) { refreshable.Refresh(); } Refreshed?.Invoke(); }); OpenOutputFolderCommand = new ReactiveCommand() .WithSubscribe(OpenOutputFolder); SelectOutputFolderCommand = new ReactiveCommand() .WithSubscribe(SelectOutputFolder); ResetFFmpegFolderCommand = new ReactiveCommand() .WithSubscribe(() => Settings.FFmpeg.FolderPath = ""); TrayLeftClickCommand = new ReactiveCommand() .WithSubscribe(() => HotKeyManager.FakeHotkey(Settings.Tray.LeftClickAction)); #endregion }
/// <summary> /// Manually updates the collection's data. /// </summary> /// <param name="force">Indicates that the refresh should ignore the value in <see cref="TrelloConfiguration.RefreshThrottle"/> and make the call to the API.</param> /// <param name="ct">(Optional) A cancellation token for async processing.</param> public Task Refresh(bool force = false, CancellationToken ct = default(CancellationToken)) { if (Auth == TrelloAuthorization.Null) #if NET45 { return(Task.Run(() => { }, ct)); } #else { return(Task.CompletedTask); } #endif Refreshed?.Invoke(this, new EventArgs()); return(PerformRefresh(force, ct)); }
void Bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Cancelled) { Notifier.Pop("Can't reach the base list!"); return; } var data = (object[])e.Result; _list = (List <List <string> >)data[0]; _basenames = (string[])data[1]; Refreshed?.Invoke(this, e); }
/// <summary> /// Refreshes the internal FileSystemWatcher /// </summary> /// <param name="returnWhenRefreshed">In case another thread is alreayd refreshing, determines wether the thread should return before the refreshing thread finishes or not.</param> private void Refresh(Boolean returnWhenRefreshed) { // Making sure another thread isn't already refreshing: if (!Monitor.TryEnter(_refreshLock)) { // if another thread IS already refreshing - wait for it to finish then return if (returnWhenRefreshed) { WaitForRefresh(); } return; } IsRefreshing = true; // 1. unsubscribe from old watcher's events. UnsubscribeFromInternalWatcherEvents(); // 2a. Keeping the current internal "EnableRaisingEvents" value Boolean currentEnableRaisingEvents = InternalWatcher.EnableRaisingEvents; // 2b. Turning off EnableRaisingEvents to avoid "locking" the watched folder InternalWatcher.EnableRaisingEvents = false; // 3. Get a new watcher IWatcher newInternalWatcher = GetReplacementWatcher(); newInternalWatcher.EnableRaisingEvents = currentEnableRaisingEvents; // 4. Disposing of the old watcher InternalWatcher.Dispose(); // 5. Place new watcher in the Internal watcher property // This also registers to the watcher's events InternalWatcher = newInternalWatcher; // Change state back to "not refreshing" IsRefreshing = false; // Notify any waiting threads that the refresh is done foreach (ManualResetEventSlim waitingThreadEvent in _waitingThreadsEvents.Values) { waitingThreadEvent.Set(); } _waitingThreadsEvents.Clear(); Monitor.Exit(_refreshLock); // Notify listeners about the refresh. Refreshed?.Invoke(this, new EventArgs()); }
public async Task Refresh() { foreach (var dataset in ParentChart?.Data?.Datasets ?? Enumerable.Empty <ChartDataset <TItem> >()) { var newData = new ChartStreamingData <TItem>(); await Refreshed.InvokeAsync(newData); await JS.AddData(JSRuntime, ParentChart.ElementId, ParentChart.Data.Datasets.IndexOf(dataset), newData.Value); } }
public async Task Refresh(DateTime fromDate, DateTime toDate, bool shouldInvoke = false) { await Dispatcher.BeginInvoke(new Action(async() => { _fromDate = fromDate; _toDate = toDate; _TRANS_LIST.ItemsSource = await App.Store.Economat.Finance.GetTransactions(_fromDate, _toDate); if (shouldInvoke) { Refreshed?.Invoke(null, EventArgs.Empty); } })); }
public async Task DoCache() { CacheInProgress = true; try { var dataToCache = await _getter.Invoke(); _memoryCache.Set(_cacheKey, dataToCache); LastCache = DateTime.UtcNow; } finally { CacheInProgress = false; Refreshed?.Invoke(); } }
public async Task Refresh() { if (!Rendered) { return; } foreach (var dataset in ParentChart?.Data?.Datasets ?? Enumerable.Empty <ChartDataset <TItem> >()) { var datasetIndex = ParentChart.Data.Datasets.IndexOf(dataset); var newData = new ChartStreamingData <TItem>(dataset.Label, datasetIndex); await Refreshed.InvokeAsync(newData); await JSModule.AddData(ParentChart.ElementId, newData.DatasetIndex, newData.Value); } }
public static void Do(IHomeContentGetter getter = null) { lock (_lock) { getter = getter ?? new RemoteXamlReader(); //开始刷新 Refreshing?.Invoke(null, new HomeContentRefreshingEventArgs()); //下载远端数据 if (!getter.TryGet(out object result)) { App.Current.Dispatcher.Invoke(() => { result = getter.Default(); }); } //刷新完成 Refreshed?.Invoke(null, new HomeContentRefreshedEventArgs(result)); } }
/// <summary> /// This function will load the actual data and then run the task which periodically refresh this data. /// It doesnt have cancellation now! /// </summary> /// <param name="interval">Default interval is 3000 = 3 seconds</param> /// <returns></returns> public async Task <string> StartRefreshingData(int interval = 5000) { try { await ReloadUtxos(); } catch (Exception ex) { Console.WriteLine("Canont load dogecoin utxos. " + ex.Message); } var first = true; // todo cancelation token _ = Task.Run(async() => { while (true) { try { if (!first) { await ReloadUtxos(); } else { first = false; } await GetListOfReceivedTransactions(); await GetListOfSentTransactions(); Refreshed?.Invoke(this, null); } catch { //await InvokeErrorEvent(ex.Message, "Unknown Error During Refreshing Data"); } await Task.Delay(interval); } }); return(await Task.FromResult("RUNNING")); }
/// <summary> /// Start refreshing the data in cycle of the interval /// </summary> /// <param name="interval"></param> /// <returns></returns> public async Task StartRefreshingData(int interval = 10000) { _ = Task.Run(async() => { while (true) { try { await LoadUtxos(); Refreshed?.Invoke(this, null); } catch (Exception ex) { Console.WriteLine("Cannot load Utxos. " + ex.Message); } await Task.Delay(interval); } }); }
private void Refresh() { Collector.Refresh(); var usageData = new SystemUsageData(); usageData.UserCpuUsed = Collector.UserCpuUsed; usageData.NonPagedSystemMemory = Collector.NonPagedSystemMemory; usageData.PagedSystemMemory = Collector.PagedSystemMemory; usageData.PrivateMemory = Collector.PrivateMemory; usageData.VirtualMemoryMemory = Collector.VirtualMemoryMemory; usageData.WorkingSet = Collector.WorkingSet; usageData.PrivilegedCpuUsed = Collector.PrivilegedCpuUsed; usageData.TotalCpuUsed = Collector.TotalCpuUsed; UsageBucket.Add(usageData); UsageBucket.RemoveOlder(maxPeriod); UsageBucket.Recalculate(); Refreshed?.Invoke(this, EventArgs.Empty); }
private void applySearchResult() { var searchResult = _searchSubsystem?.SearchResult?.RelevanceById; _filteredModels.Clear(); _filteredModels.Add(_model); var models = _models.Where(m => searchResult == null || searchResult.ContainsKey(m.Id)); foreach (var model in models) { _filteredModels.Add(model); _cardIdsInFilteredDecks.UnionWith(model.Deck.MainDeck.Order); _cardIdsInFilteredDecks.UnionWith(model.Deck.Sideboard.Order); } _viewDeck.RefreshData(); Refreshed?.Invoke(this); }
void OnRefresh() { VideoWritersViewModel.RefreshCodecs(); AudioSource.Refresh(); #region Webcam var lastWebcamName = WebCamProvider.SelectedCam?.Name; WebCamProvider.Refresh(); var matchingWebcam = WebCamProvider.AvailableCams.FirstOrDefault(M => M.Name == lastWebcamName); if (matchingWebcam != null) { WebCamProvider.SelectedCam = matchingWebcam; } #endregion Refreshed?.Invoke(); }
public void Reload() { try { _Resource?.Dispose(); _Resource = null; if (!File.Exists(_Link)) { Watcher.EnableRaisingEvents = false; Loaded = false; Reloaded?.Invoke(this, EventArgs.Empty); Refreshed?.Invoke(this, EventArgs.Empty); return; } try { Watcher.Filter = Path.GetFileName(_Link); Watcher.Path = Path.GetDirectoryName(Path.GetFullPath(_Link)); Watcher.EnableRaisingEvents = true; } catch { Watcher.EnableRaisingEvents = false; } _Resource = new T(); _Resource.Open(_Link); Loaded = true; } catch { Loaded = false; } Reloaded?.Invoke(this, EventArgs.Empty); Refreshed?.Invoke(this, EventArgs.Empty); }
internal void Refresh() { LastUpdateTime = Environment.TickCount; Refreshed.Invoke(this); }