cancellation

Multi-Threading Cross-Class Cancellation with TPL

落花浮王杯 提交于 2019-12-05 06:58:13
问题 All, I have a long running process that I run on a background thread (with cancellation support) using the Task Paralell Library (TPL). The code for this long running taks is contained within Class Validation , and when the method public bool AsyncRunValidationProcess(TaskScheduler _uiScheduler, CancellationToken _token, dynamic _dynamic = null) { try { // Note: _uiScheduler is used to update the UI thread with progress infor etc. for (int i = 0; i < someLargeLoopNumber; i++) { //

Abort ajax request in a promise

 ̄綄美尐妖づ 提交于 2019-12-05 04:30:09
I'm building a form validation and to learn promises I decided to implement asynchronous validation functions using promise pattern: var validateAjax = function(value) { return new Promise(function(resolve, reject) { $.ajax('data.json', {data: {value: value}}).success(function(data, status, xhr) { if (data.valid) { resolve(xhr) } else { reject(data.message) } }).error(function(xhr, textStatus) { reject(textStatus) }) }) } //... var validators = [validateAjax]; $('body').delegate('.validate', 'keyup', function() { var value = $('#the-input').val(); var results = validators.map(function

How to cancel window closing in MVVM WPF application

痞子三分冷 提交于 2019-12-05 00:43:25
How can I cancel exiting from particular form after Cancel button (or X at the top right corner, or Esc) was clicked? WPF: <Window ... x:Class="MyApp.MyView" ... /> <Button Content="Cancel" Command="{Binding CancelCommand}" IsCancel="True"/> </Window> ViewModel: public class MyViewModel : Screen { private CancelCommand cancelCommand; public CancelCommand CancelCommand { get { return cancelCommand; } } public MyViewModel() { cancelCommand = new CancelCommand(this); } } public class CancelCommand : ICommand { public CancelCommand(MyViewModel viewModel) { this.viewModel = viewModel; } public

why does pthread_exit throw something caught by ellipsis?

旧巷老猫 提交于 2019-12-04 23:07:14
if the function called by pthread_create has the following structure try{ ...code.... pthread_detach(pthread_self()); pthread_exit(NULL); }catch(...){ std::cout<<"I am here"<<std::endl; } why does the exception handler for ellipsis get called at the execution of pthread_exit ? (note that std::exception , for instance, are not thrown) eran At least in GCC pthread_exit might throw an ___forced_unwind exception, that is used for unwinding the stack during the thread exit. It does not inherit from std::exception , and therefore cannot be caught as one. If you do catch that exception, be sure to re

When is POSIX thread cancellation not immediate?

删除回忆录丶 提交于 2019-12-04 16:14:24
The POSIX specifies two types for thread cancellation type: PTHREAD_CANCEL_ASYNCHRONOUS , and PTHREAD_CANCEL_DEFERRED (set by pthread_setcanceltype(3) ) determining when pthread_cancel(3) should take effect. By my reading, the POSIX manual pages do not say much about these, but Linux manual page says the following about PTHREAD_CANCEL_ASYNCHRONOUS : The thread can be canceled at any time. (Typically, it will be canceled immediately upon receiving a cancellation request, but the system doesn't guarantee this.) I am curious about the meaning about the system doesn't guarantee this . I can easily

Can jQuery deferreds be cancelled?

给你一囗甜甜゛ 提交于 2019-12-04 14:59:39
问题 I have a situation where I want to cancel a deferred. The deferred is associated with an ajax call. Why I am using deferreds I don't use the normal xhr objects returned by $.ajax. I'm using jsonp, which means I can't use HTTP status codes for error handling and have to embed them in the responses. The codes are then examined and an associated deferred object is marked as resolved or rejected accordingly. I have a custom api function that does this for me. function api(options) { var url =

Whether method cancel() in java.util.concurrent.Future should be blocking?

懵懂的女人 提交于 2019-12-04 10:52:42
I'm trying to implement Future<> interface in my project. But it looks like documentation is a little bit vague for it. From official documentation we can deduce: Method cancel() does not throw exceptions like InterruptedException or ExecutionException. Moreover it has no the variant with timeout. So it looks like, it should NOT be blocking. Documentation says After this method returns, subsequent calls to isDone() will always return true. but boolean isDone() Returns true if this task completed. So if we run cancel() while the task is processing and cannot be canceled, this method should wait

Exception in async methods is not caught

非 Y 不嫁゛ 提交于 2019-12-04 06:26:02
问题 The following code does not catch my OperationCancelException which is thrown by calling ct.ThrowIfCancellationRequested . public partial class TitleWindow : Window, IAsyncInitialization { public Task Initialization{get; private set;} CancellationTokenSource cts; public TitleWindow() { InitializeComponent(); cts = new CancellationTokenSource(); } private void Window_Loaded(object sender, RoutedEventArgs e) { try { cts.Cancel(); Initialization = GetCancelExceptionAsync(cts.Token); } catch

Implementing cancellable syscalls in userspace

百般思念 提交于 2019-12-04 02:51:15
I'm working on implementing pthread cancellation on Linux without any of the "unpleasant behavior" (some might say bugs) discussed in some of my other recent questions. The Linux/glibc approach to pthread cancellation so far has been to treat it as something that doesn't need kernel support, and that can be handled at the library level purely by enabling asynchronous cancellation before making a syscall, and restoring the previous cancellation state after the syscall returns. This has at least 2 problems, one of them extremely serious: Cancellation can act after the syscall has returned from

How to stop a java code from running using a stop button

*爱你&永不变心* 提交于 2019-12-03 12:16:26
问题 I have a button that calls a method from the backing Bean. This method allows to extract data from parsing html code. While the method is running i have a dialog showing a progress bar and a command button Cancel . I need when the user click the cancel button the method called by the extract button stops. This is my html code: <p:commandButton value="Start" style="width: 12%;height: 100%" update=":confirmPurchase, :confirmPurchaseTest, :mainform" id="extractbutton" ajax="true" widgetVar=