public void Command_applicability_can_be_validated_by_the_command_class() { var cancel = new Cancel(); var order = new Order(); order.IsValidTo(cancel).Should().Be(true); order.Apply(new Deliver()); order.IsValidTo(cancel).Should().Be(false); }
public OperationPending(string langKey, string TaskName, ProgressHandler progressHandler, Cancel cancelCallback = null, bool AutoClose = false) : base(langKey) { InitializeComponent(); this.progressHandler = progressHandler; this.TaskName = TaskName; this.CancelCallback = cancelCallback; this.AutoClose = AutoClose; this.LangKey = langKey; Init(); }
public void AuthorizationPolicy_For_returns_an_instance_based_on_the_actual_rather_than_declared_type_of_the_principal() { AuthorizationFor<Customer>.ToApply<Cancel>.ToA<Order> .Requires((a, b, c) => true); IPrincipal iprincipal = new Customer(); var customer = new Customer(); var cancel = new Cancel(); var order = new Order(); iprincipal.IsAuthorizedTo(cancel, order).Should().Be(true); customer.IsAuthorizedTo(cancel, order).Should().Be(true); }
public async Task new_commands_issued_after_cancel_are_executed() { var kernel = CreateKernel(); var cancelCommand = new Cancel(); var commandToCancel = new CancellableCommand(); var commandToRun = new SubmitCode("1"); var _ = kernel.SendAsync(commandToCancel); await kernel.SendAsync(cancelCommand); await kernel.SendAsync(commandToRun); KernelEvents .Should() .ContainSingle <CommandSucceeded>(c => c.Command == commandToRun); }
protected virtual void OnCancel(CancelEventArgs e) { Cancel?.Invoke(this, e); // check if user canceled if (e.Cancel) { // cancel closing (when ShowDialog is used) this.ParentForm.DialogResult = DialogResult.None; } else { // ensure parent form is closed (even when ShowDialog is not used) if (this.AllowAutoClose) { this.ParentForm.Close(); } } }
private void ShuffleList <T>(T[] list, Cancel cancelFnc, int numOfTranspositions = -1) { if (numOfTranspositions == -1) { numOfTranspositions = list.Length; } for (int i = 0; i < numOfTranspositions; i++) { if (cancelFnc != null && cancelFnc()) { return; } int index1 = r.Next(0, list.Length); int index2 = r.Next(0, list.Length); var temp = list[index1]; list[index1] = list[index2]; list[index2] = temp; } }
public async Task can_cancel_user_infinite_loops() { var kernel = CreateKernel(); var cancelCommand = new Cancel(); var commandToRun = new SubmitCode("while(true){ await Task.Delay(10); }", targetKernelName: "csharp"); var commandToInterrupt = kernel.SendAsync(commandToRun); await kernel.SendAsync(cancelCommand); await commandToInterrupt; KernelEvents .Should() .ContainSingle <CommandFailed>(c => c.Command == commandToRun); }
// Overridden so that an event is fired on close based on the confirmation state protected override void Close() { base.Close(); if (_confirmed) { if (Confirm != null) { Confirm.Invoke(this, EventArgs.Empty); } } else { if (Cancel != null) { Cancel.Invoke(this, EventArgs.Empty); } } }
/// <inheritdoc /> public override bool HandleDialog(Window window) { if (CanHandleDialog(window)) { _hwnd = window.Hwnd; if (_pressReTry) { ReTry.Click(); } else { Cancel.Click(); } return(true); } return(false); }
void BackgroundWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Error != null) { Statistical.SetProgressRate(Color.Maroon); Console.WriteLine(e.Error.StackTrace); } else if (e.Cancelled) { Statistical.SetProgressRate(e.Cancelled); Statistical.SetProgressRate(Color.Ivory); } else { Statistical.SetProgressRate((bool)e.Result); Statistical.SetProgressRate(Color.Ivory); } Cancel.Dispose(); }
public void Should_Cancel_Payment() { CreateCancelRequest request = new CreateCancelRequest(); request.ConversationId = "123456789"; request.Locale = Locale.TR.GetName(); request.PaymentId = "1"; request.Ip = "127.0.0.1"; Cancel cancel = Cancel.Create(request, options); PrintResponse <Cancel>(cancel); Assert.IsNotNull(cancel.SystemTime); Assert.AreEqual(Status.SUCCESS.ToString(), cancel.Status); Assert.AreEqual(Locale.TR.GetName(), cancel.Locale); Assert.AreEqual("123456789", cancel.ConversationId); Assert.AreEqual("1", cancel.PaymentId); }
public AccessUsers() { Cancel.SetVisible(false); if (ActiveDirectoryProvider.Instance == ActiveDirectoryProvider.Empty) // hide "Add Active Directory User" button if AD is not enabled { AddADUser.SetVisible(false); } bool shouldCache = ActiveDirectoryProvider.Instance.GetUsers().Count() > _AdLimit; this.ReloadADUsers.SetVisible(shouldCache); foreach (var attr in this.GetAttributes("ADUser", "Username")) { if (attr is PXADUsersSelectorAttribute) { ((PXADUsersSelectorAttribute)attr).UseCached = shouldCache; } } }
public NewItem() { InitializeComponent(); // // TODO: [rlittlesii: July 04, 2020] fix once Sextant.Plugins.Popup is completed. // ViewModel = new NewItemViewModel(); Save .Events() .Pressed .Select(x => Unit.Default) .InvokeCommand(this, x => x.ViewModel.Save); Cancel .Events() .Pressed .Select(x => Unit.Default) .InvokeCommand(this, x => x.ViewModel.Cancel); }
//Cancel public static void CancelSelectProductDetails() { log4net.Config.XmlConfigurator.Configure(); ILog logger = LogManager.GetLogger(typeof(SelectProductDetailsPage)); try { Cancel.Click(); Wait.WaitVisible(FrameYes, 10); FrameYes.Click(); } catch (Exception e) { logger.Error("Cancel Select Product Details failed due to : " + e); test.Fail("Cancel Select Product Details failed."); //**Closing browser Driver.Quit(); } }
public void PinPageControl(object sender, KeyEventArgs e) { Digit1.TextBoxControl(Digit2, Digit3, Digit4, e); if (e.Key == Key.F9) { if ((Digit1.PinFieldValidator(Digit2, Digit3, Digit4) == 1)) { Enter.PerformClick(); } else { StateInfo.Content = "Enter All Four Digits Of Your Pin"; } } else if (e.Key == Key.F8) { Cancel.PerformClick(); } }
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { if (keyData == Keys.Escape) { this.Close(); } else if (keyData == (Keys.Control | Keys.S)) { Save?.Invoke(); } else if (keyData == (Keys.Control | Keys.E)) { Edit?.Invoke(); } else if (keyData == (Keys.Control | Keys.X)) { Cancel?.Invoke(); } return(base.ProcessCmdKey(ref msg, keyData)); }
// PUT api/<controller>/5 public HttpResponseMessage Put(int id, Cancel ca) { try { if (id == ca.CancelNo) { db.Entry(ca).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(new HttpResponseMessage(HttpStatusCode.OK)); } else { return(new HttpResponseMessage(HttpStatusCode.NotFound)); } } catch (Exception ex) { return(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } }
public async Task <bool> CancelAsync(string bookingNumber) { // Wait for login to actually redirect to the customer profile page await _session.WaitForElementToAppearAsync(Cancel.BookingsTable); var clicked = await _session.TryInvokeOnElementAsync(Cancel.CancelLink(bookingNumber), x => x.Click()); if (!clicked) { return(false); } await _session.WaitForElementToAppearAsync(Cancel.CancelPopupMessageDiv); await _session.InvokeOnElementAsync(Cancel.ConfirmButton, x => x.Click()); await _session.WaitForAsync(driver => driver.Title.Contains("Booking annulleret")); return(true); }
public async Task cancel_issues_CommandSucceeded() { using var kernel = CreateKernel() .LogCommandsToPocketLogger() .LogEventsToPocketLogger(); var cancelCommand = new Cancel(); var commandToCancel = new SubmitCode(@" using Microsoft.DotNet.Interactive; while(!KernelInvocationContext.Current.CancellationToken.IsCancellationRequested){ await Task.Delay(10); }", targetKernelName: "csharp"); var _ = kernel.SendAsync(commandToCancel); await kernel.SendAsync(cancelCommand); KernelEvents .Should() .ContainSingle <CommandSucceeded>(c => c.Command == cancelCommand); }
public byte[] ToByteArray() { List <byte> result = new List <byte>(25); result.Add(PA); result.Add(MA); result.Add(Speed); result.Add(Move); result.Add(Jump); result.AddRange(PermanentStatuses.ToByteArray()); result.AddRange(StatusImmunity.ToByteArray()); result.AddRange(StartingStatuses.ToByteArray()); result.Add(Absorb.ToByte()); result.Add(Cancel.ToByte()); result.Add(Half.ToByte()); result.Add(Weak.ToByte()); result.Add(Strong.ToByte()); return(result.ToArray()); }
private void textBox_PreviewKeyDown(object sender, KeyEventArgs e) { if ((e.Key == Key.B) && (YesBind != null)) { YesBind.Invoke(this, new EventArgs()); } else if ((e.Key == Key.Y) && (Yes != null)) { Yes.Invoke(this, new EventArgs()); } else if (((e.Key == Key.N) || (e.Key == Key.Enter) || (e.Key == Key.Space)) && (No != null)) { No.Invoke(this, new EventArgs()); } else if ((e.Key == Key.Escape) && (Cancel != null)) { Cancel.Invoke(this, new EventArgs()); } e.Handled = true; }
private async void SaveAction() { ModelsShared.Models.port port = new ModelsShared.Models.port { CityID = this.CityID, Code = this.Code, PortType = this.PortType, Id = this.Id, Name = this.Name, CityName = CityCollection.SelectedItem.CityName }; var res = await Collection.Add(port); if (res != null) { MessageBoxButton btn = MessageBoxButton.OK; var result = ModernDialog.ShowMessage("Data Saved?", "Message Dialog", btn); Cancel.Execute(null); } }
private void DataGridView1_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Insert) // && (e.Alt || e.Control || e.Shift)) { //AgregarRegistro(); bindingNavigatorAddNewItem.PerformClick(); } else if (e.KeyCode == Keys.Delete) // && (e.Alt || e.Control || e.Shift)) { //EliminarRegistro(); bindingNavigatorDeleteItem.PerformClick(); } else if (e.KeyCode == Keys.Escape) // && (e.Alt || e.Control || e.Shift)) { Cancel.PerformClick(); } //else if (e.KeyCode == Keys.Enter) //{ // //OK.PerformClick(); //} }
public void Should_Cancel_Payment() { CreateCancelRequest request = new CreateCancelRequest(); request.ConversationId = "123456789"; request.Locale = Locale.TR.ToString(); request.PaymentId = "1"; request.Ip = "85.34.78.112"; Cancel cancel = Cancel.Create(request, options); PrintResponse <Cancel>(cancel); Assert.AreEqual(Status.SUCCESS.ToString(), cancel.Status); Assert.AreEqual(Locale.TR.ToString(), cancel.Locale); Assert.AreEqual("123456789", cancel.ConversationId); Assert.IsNotNull(cancel.SystemTime); Assert.IsNull(cancel.ErrorCode); Assert.IsNull(cancel.ErrorMessage); Assert.IsNull(cancel.ErrorGroup); }
// DELETE api/<controller>/5 public HttpResponseMessage Delete(int id) { try { Cancel c = db.Cancels.Find(id); if (c != null) { db.Cancels.Remove(c); db.SaveChanges(); return(new HttpResponseMessage(HttpStatusCode.OK)); } else { return(new HttpResponseMessage(HttpStatusCode.NotFound)); } } catch (Exception ex) { return(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } }
public async Task can_cancel_user_loop_using_CancellationToken() { var kernel = CreateKernel(); var cancelCommand = new Cancel(); var commandToRun = new SubmitCode(@" using Microsoft.DotNet.Interactive; while(!KernelInvocationContext.Current.CancellationToken.IsCancellationRequested){ await Task.Delay(10); }", targetKernelName: "csharp"); var commandToInterrupt = kernel.SendAsync(commandToRun); await kernel.SendAsync(cancelCommand); await commandToInterrupt; KernelEvents .Should() .ContainSingle <CommandFailed>(c => c.Command == commandToRun); }
private void OnScan() { ListARFCNs.Clear(); //TransferDB.ARFCNs.Clear(); SelectedUnit = Units[0]; UpdateBand(); Computer cpu = Computers.FirstOrDefault(c => c.Unit_ID == SelectedUnit.ID); if (Scanner.Start(cpu, 1, BroadcastIP, ScannerListenerPort, band, Gain, Speed, sample_rate, 0)) { IsScanVisible = Visibility.Collapsed; IsCancelVisible = Visibility.Visible; Cancel.RaiseCanExecuteChanged(); if (!listenerWorker.IsBusy) { listenerWorker.RunWorkerAsync(ScannerListenerPort); } IsEnabled = false; IsEnabledSession = false; } }
/// <summary> /// Ödeme Talebi İadesi /// </summary> /// <param name="refundPaymentRequest">Request</param> /// <returns>Result</returns> public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest) { var refundResult = new RefundPaymentResult(); if (!refundPaymentRequest.IsPartialRefund) { CreateCancelRequest request = new CreateCancelRequest(); request.ConversationId = refundPaymentRequest.Order.CustomOrderNumber; request.Locale = Locale.TR.ToString(); request.PaymentId = refundPaymentRequest.Order.AuthorizationTransactionId; request.Ip = refundPaymentRequest.Order.CustomerIp; Cancel cancel = Cancel.Create(request, HelperApiOptions.GetApiContext(_iyzicoPayPaymentSettings)); if (cancel.Status == "success") { refundResult.NewPaymentStatus = PaymentStatus.Refunded; } else { refundResult.AddError(cancel.ErrorGroup); } } else { string[] list = refundPaymentRequest.Order.AuthorizationTransactionResult.Split('-'); CreateRefundRequest request = new CreateRefundRequest(); request.ConversationId = refundPaymentRequest.Order.CustomOrderNumber; request.Locale = Locale.TR.ToString(); request.PaymentTransactionId = list[0]; request.Price = refundPaymentRequest.AmountToRefund.ToString("##.###").Replace(',', '.'); request.Ip = refundPaymentRequest.Order.CustomerIp; request.Currency = Currency.TRY.ToString(); Iyzico.Models.Refund refund = Iyzico.Models.Refund.Create(request, HelperApiOptions.GetApiContext(_iyzicoPayPaymentSettings)); if (refund.Status == "success") { refundResult.NewPaymentStatus = PaymentStatus.PartiallyRefunded; } } return(refundResult); }
public AlertPopupPage(bool isInformative, string textInfo, string cancelText = "Отмена", string confirmText = "Понятно") { // Это для определения стиля кнопки Ок IsInformative = isInformative; InitializeComponent(); //Инициализируем все остальное InfoLabel.Text = textInfo; ButtonCancel.Text = cancelText; ButtonConfirm.Text = confirmText; ButtonCancel.Clicked += (s, e) => { Cancel?.Invoke(s, e); }; ButtonConfirm.Clicked += (s, e) => { Confirm?.Invoke(s, e); }; Confirm += (s, e) => { Navigation.PopPopupAsync(); }; Cancel += (s, e) => { Navigation.PopPopupAsync(); }; // Присваиваем переменные для биндинга BindingContext = this; // Костыльно в плане паттерна, но лучше, чем писать конвертер True в False :) ButtonCancel.IsVisible = !isInformative; ButtonConfirm.Style = (Style)(isInformative ? Application.Current.Resources["ButtonStandardWhite"] : Application.Current.Resources["ButtonStandard"]); }
private void DrawButtons() { btnSave = new Button("Save") { X = Pos.Right(this) - 64, Y = Pos.Bottom(this) - 4 }; btnSave.Clicked = () => SaveScript(); Add(btnSave); btnCancel = new Button("Cancel") { X = Pos.Right(this) - 75, Y = Pos.Bottom(this) - 4 }; btnCancel.Clicked = () => Cancel?.Invoke(); Add(btnCancel); }
/// <summary> /// 设置并计算界面元素正确的位置 /// </summary> private void SetControlPosition() { double HorizonLocation = SplashImageRect.X + (SplashImageRect.Width * 0.5); double VerticalLocation = SplashImageRect.Y + (SplashImageRect.Height * 0.75); SplashProgressRing.SetValue(Canvas.LeftProperty, HorizonLocation - (SplashProgressRing.Width * 0.5)); SplashProgressRing.SetValue(Canvas.TopProperty, VerticalLocation); Display.SetValue(Canvas.LeftProperty, HorizonLocation - (Display.Width * 0.5)); Display.SetValue(Canvas.TopProperty, VerticalLocation + SplashProgressRing.Height + 20); Continue.SetValue(Canvas.LeftProperty, HorizonLocation - 75); Continue.SetValue(Canvas.TopProperty, VerticalLocation + SplashProgressRing.Height + Display.Height + 20); Cancel.SetValue(Canvas.LeftProperty, HorizonLocation + 5); Cancel.SetValue(Canvas.TopProperty, VerticalLocation + SplashProgressRing.Height + Display.Height + 20); extendedSplashImage.SetValue(Canvas.LeftProperty, SplashImageRect.X); extendedSplashImage.SetValue(Canvas.TopProperty, SplashImageRect.Y); extendedSplashImage.Height = SplashImageRect.Height; extendedSplashImage.Width = SplashImageRect.Width; }
/// <summary> /// Fire the cancel event. /// </summary> protected virtual void OnCancel() { try { if (worker.IsBusy) { worker.CancelAsync(); } } catch { // Ignore } try { Cancel.Fire(this); } catch (Exception ex) { ErrorLog.DumpError(ex); } }
public async Task when_cancelling_command_it_reports_what_command_was_cancelled() { // todo: this test is flaky and timeouts in CI while (true) { using var kernel = CreateKernel(); var cancelCommand = new Cancel(); var commandToCancel = new SubmitCode(@" using Microsoft.DotNet.Interactive; var cancellationToken = KernelInvocationContext.Current.CancellationToken; while(!cancellationToken.IsCancellationRequested){ await Task.Delay(10); }", targetKernelName: "csharp"); var resultForCommandToCancel = kernel.SendAsync(commandToCancel); var result = await kernel.SendAsync(cancelCommand); var cancellationEvents = result.KernelEvents.ToSubscribedList(); try { await resultForCommandToCancel.Timeout(10.Seconds()); cancellationEvents.Should() .ContainSingle <CommandCancelled>() .Which .CancelledCommand .Should() .Be(commandToCancel); break; } catch (TimeoutException) { } } }
private void Init() { if (this.Task != null) { this.TaskName = (string)this.Task.Parameters[0]; this.progressHandler = (ProgressHandler)this.Task.Parameters[1]; this.CancelCallback = ((Cancel)this.Task.Parameters[2]); this.AutoClose = ((bool)this.Task.Parameters[3]); } this.progressHandler.OnChange += (s, e) => Dispatcher.Invoke((Action)delegate() { ChangeProgress(); }); this.progressHandler.OnComplete += (s, e) => Dispatcher.Invoke((Action)delegate() { OperationComplete(); }); if (this.CancelCallback == null) this.CancelButton.Visibility = System.Windows.Visibility.Collapsed; if (this.AutoClose) this.ConfirmButton.Visibility = System.Windows.Visibility.Collapsed; SetCloseable(false); this.ChangeProgress(); if (progressHandler.Progress == 100f) this.OperationComplete(); }
private void lstAlbums_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (m_Mpc == null || !m_Mpc.Connected) return; ListBox list = sender as ListBox; if (list.SelectedItem != null) { Dictionary<ScopeSpecifier, string> search = new Dictionary<ScopeSpecifier, string>(); ListBox listBox = null; if (tabBrowse.SelectedIndex == 0 && lstArtist.SelectedItem != null) { string artist = lstArtist.Selected().Artist(); search[ScopeSpecifier.Artist] = artist; listBox = lstAlbums; } else if (tabBrowse.SelectedIndex == 1 && lstGenres.SelectedItem != null) { string genre = lstGenres.SelectedItem.ToString(); if (genre == Mpc.NoGenre) genre = string.Empty; search[ScopeSpecifier.Genre] = genre; listBox = lstGenresAlbums; } var album = listBox.Selected(); search[ScopeSpecifier.Album] = album.Album(); Action<Cancel, Action<Action>> populate = (c, call) => { try { if (c.cancel) return; if (album != null) { album.Related.Do(r => r.Selected = true); if (e != null) { var old = e.RemovedItems.OfType<ListboxEntry>().FirstOrDefault(); if (old != null && !(album.Related != null && album.Related.Contains(old))) old.Related.Do(r => r.Selected = false); } if (c.cancel) return; call(() => { listBox.ScrollIntoView(album); }); } try { m_Tracks = m_Mpc.Find(search); if (c.cancel) return; if (album != null) { Albums[album.Artist + ":" + album.Album] = album; album.Tracks = () => m_Tracks; if (album.Info == null) album.Info = new ObservableCollection<object>(); m_ArtDownloader.Now(album); } m_Tracks.Do(m => m.AlbumEntry = album); var selection = m_Tracks.ToDictionary(m => m.File); var all = m_Tracks .OrderBy(m => m.Disc).ThenBy(m => m.TrackNo).ThenBy(m => m.Title, Utilities.VersionComparer.Instance) .GroupBy(m => dir.Replace(m.File, "$1")) .Where(g => { if (album != null && album.Album != "Misc") FindInfo(album.Info, g.Key, 20, Dispatcher); return true; }) .SelectMany(Utilities.Try<IGrouping<string, MpdFile>, IEnumerable<MpdFile>>(g => m_Mpc.ListAllInfo(g.Key) .OrderBy(m => m.Disc).ThenBy(m => m.TrackNo).ThenBy(m => m.Title, Utilities.VersionComparer.Instance) .Where(m => (m.Supplement = !selection.Remove(m.File)) || true) )) .ToList(); if (c.cancel) return; all.GroupBy(m => m.Artist).Do(a => a.GroupBy(m => m.Album).Do(b => { var i = new ListboxEntry() { Type = ListboxEntry.EntryType.Album, Artist = a.Key, Album = b.Key, Tracks = () => b, }; b.Do(m => m.AlbumEntry = i); m_ArtDownloader.Soon(i); })); all.AddRange(selection.Values); if (c.cancel) return; call(() => { if (album != null) lstInfo.ItemsSource = album.Info; lstTracks.ItemsSource = all; ScrollTracksToLeft(); }); } catch (Exception ex) { ShowException(ex); return; } } finally { lock(lstArtist_Jobs) lstArtist_Jobs.Remove(c); }}; var cancel = new Cancel(); Cancel.Set(lstArtist_Jobs, cancel); if (navigating) populate(cancel, x => x()); else populate.BeginInvoke(cancel, (Action<Action>)(x => Dispatcher.BeginInvoke(x)), populate.EndInvoke, null); } else { m_Tracks = null; lstTracks.ItemsSource = null; } }
private void lstArtist_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (m_Mpc == null || !m_Mpc.Connected) return; if (lstArtist.SelectedItem == null) { lstAlbums.ItemsSource = new MpdFile[0]; return; } var a = lstArtist.Selected(); ArtistLabel.DataContext = a; if (a != null) if (a.Albums != null) lstAlbums_Show(a.Albums); else { string artist = a.Artist(); Action<Cancel, Action<Action>> populate = (c, call) => { try { IEnumerable<string> albums = null; if (c.cancel) return; try{ albums = m_Mpc.List(ScopeSpecifier.Album, ScopeSpecifier.Artist, artist); }catch (Exception ex){ ShowException(ex); return; } if (c.cancel) return; ListboxEntry last = null; if (a.Artist == "Misc") albums = albums.Where(_album => _album != "Misc"); a.Albums = albums.Select(_album => { var album = string.IsNullOrEmpty(_album) ? Mpc.NoAlbum : _album; var display = recording.Replace(album, "$1$2"); var grouping = numbers.Replace(punct.Replace(display, " ").ToLower(), x => numbers.GetGroupNumbers().Select(i => i > 0 && x.Groups[i].Success ? (i < 22 ? i - 1 : i < 29 ? 20 + (i - 21) * 20 : i < 41? i - 29 : int.Parse(x.Groups[i].Value)) : 0 ).Sum().ToString("ZZ000") ); return new ListboxEntry() { Type = ListboxEntry.EntryType.Album, Artist = artist, Album = album, Display = display, Grouping = grouping, }; }) .OrderBy(entry => entry.Grouping).ThenBy(entry => entry.Album) .Select(entry => { if (last != null && entry.Grouping == last.Grouping) { var rel = last.Related ?? new ObservableCollection<ListboxEntry>(); if (rel.Count == 0) rel.Add(last); rel.Add(entry); entry.Related = last.Related = rel; entry.Head = false; } last = entry; return entry; }).ToList(); if (c.cancel) return; call(() => lstAlbums_Show(a.Albums)); } finally { lock(lstArtist_Jobs) lstArtist_Jobs.Remove(c); }}; var cancel = new Cancel(); Cancel.Set(lstArtist_Jobs, cancel); if (navigating) populate(cancel, x => x()); else populate.BeginInvoke(cancel, (Action<Action>)(x => Dispatcher.BeginInvoke(x)), populate.EndInvoke, null); m_ArtistArtDownloader.Soon(a); } }
public static void Set(ICollection<Cancel> C, Cancel c) { #if CancelConcurrent while(true) try { C.Do(_ => _.cancel = true); break; } catch { System.Threading.Thread.Sleep(10); } #else lock(C) { C.Do(_ => _.cancel = true); C.Add(c); } #endif }