cancellation

Can jQuery deferreds be cancelled?

那年仲夏 提交于 2019-12-03 09:20:57
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 = settings('api') + options.url; var deferred = $.Deferred(function(){ this.done(options.success); this.fail

How to retract a message in RabbitMQ?

懵懂的女人 提交于 2019-12-03 09:06:29
问题 I've got something like a job queue over RabbitMQ and, upon a request to cancel a job, I'd like to retract the tasks that have not yet started processing (their messages have not been ack'd), which corresponds to retracting these messages from the queues that they've been routed to. I haven't found this functionality in AMQP or in the RabbitMQ API; perhaps I haven't searched well enough? Or will I have to use a workaround (it's not hard, but still)? 回答1: I would solve this scenario by having

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

瘦欲@ 提交于 2019-12-03 02:47:10
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="ButtonExtract" actionListener="#{mailMB.searchEmails()}" icon="ui-icon-disk" styleClass="ui-priority

Any way to differentiate Cancel and Timeout

大兔子大兔子 提交于 2019-12-03 02:37:32
I have some code that is validating some data by making calls to a number of other services. I start all of the calls in parallel and then wait until at least one of them finishes. If any of the requests fail, I don't care about the result of the other calls. I make the calls with HttpClient and I have passed an HttpMessageHandler in that does a bunch of logging. Essentially: protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { HttpResponseMessage response = null; try { response = await base.SendAsync(request,

How to retract a message in RabbitMQ?

孤街浪徒 提交于 2019-12-03 00:44:09
I've got something like a job queue over RabbitMQ and, upon a request to cancel a job, I'd like to retract the tasks that have not yet started processing (their messages have not been ack'd), which corresponds to retracting these messages from the queues that they've been routed to. I haven't found this functionality in AMQP or in the RabbitMQ API; perhaps I haven't searched well enough? Or will I have to use a workaround (it's not hard, but still)? I would solve this scenario by having the worker check some sort of authoritative data source to determine if the the job should proceed or not.

Cancel ThreadPool .QueueUserWorkItem Task

ぃ、小莉子 提交于 2019-12-02 05:33:37
问题 I need to cancel a background task started using ThreadPool.QueueUserWorkItem(...). I know a BackgroundWorker has constructs especially for this sort of thing, but I believe it's overkill in this case, since no user interface is involved. By cancellation, I simply mean force the completion of the callback method. What are the pitfalls of adding something like the following to my class? // Cancellation Property. private bool _canceled; public bool CancelTask { get { return _canceled; } set {

Providing cancellation if polling CancellationToken is not possible

对着背影说爱祢 提交于 2019-12-02 05:03:20
问题 Here's a (silly) example of a method that blocks the caller's thread but does not support cancellation: Public Sub WorkUntil5() Threading.SpinWait.SpinUntil(Function() Now.Hour >= 17) End Sub In the worst case scenario, calling this method takes 17 hours to return. Pretend that I don't have access to the source code of this method. How do I wrap the call in a method that takes a CancellationToken? The goal is to let WorkUntil5() run until cancellation is requested. At that point the call

Cancel ThreadPool .QueueUserWorkItem Task

て烟熏妆下的殇ゞ 提交于 2019-12-02 02:27:13
I need to cancel a background task started using ThreadPool.QueueUserWorkItem(...). I know a BackgroundWorker has constructs especially for this sort of thing, but I believe it's overkill in this case, since no user interface is involved. By cancellation, I simply mean force the completion of the callback method. What are the pitfalls of adding something like the following to my class? // Cancellation Property. private bool _canceled; public bool CancelTask { get { return _canceled; } set { _canceled = value; } } public void DoSomeTask() { int iterations = 50; ThreadPool.QueueUserWorkItem(new

How to cancel Task C#

烈酒焚心 提交于 2019-12-01 07:31:26
问题 I have a Task which retrieves some data from a Web Service. The Webservice should only get called when I open a page (this is Xamarin.Forms) and it should only run if there isn't another version of the task running - This part works fine. When I move away from the page, I want to cancel the Task - I can't seem to get that piece working. When OnAppearing() , OnDisappearing() , OnAppearing() is hit before the webservice returns the data, logs just write "Task has attempted to start..." which

F# How Async<'T> cancellation works?

我怕爱的太早我们不能终老 提交于 2019-12-01 03:16:09
I was pretty comfortable with how async cancellations where done in C# with the TPL, but I am a little bit confused in F#. Apparently by calling Async.CancelDefaultToken() is enough to cancel outgoing Async<'T> operations. But they are not cancelled as I expected, they just... vanishes... I cannot detect properly the cancellation and tear down the stack properly. For example, I have this code that depends on a C# library that uses TPL: type WebSocketListener with member x.AsyncAcceptWebSocket = async { let! client = Async.AwaitTask <| x.AcceptWebSocketAsync Async.DefaultCancellationToken if