Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4078734
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:42:42+00:00 2026-05-20T17:42:42+00:00

I have a fairly simple, though expensive, task that I need to run in

  • 0

I have a fairly simple, though expensive, task that I need to run in the background, which is the standard NSOperation situation. I also need to make sure the operation supports cancellation, and stops appropriately. Given that requirement, which is the better approach: Just wrapping up the expensive method call in an NSInvocationOperation, or writing an NSOperation subclass from scratch?

Here’s my thinking so far. NSInvocationOperations are my first choice, and are what I’ve used in the past, because the task is so simple that I don’t want to write a whole class with all the NSOperation boilerplate code just to execute it. What now makes me hesitate is the fact that there doesn’t really seem to be a way for an method executed in an NSInvocationOperation to check for cancellation that doesn’t set off the hackery alarm in my head. See this question for some examples of said hackery. I’ve tried them, and they do work, they just also feel icky.

Writing an NSOperation subclass, as mentioned before, seems like overkill to perform the simple task, but there is no doubt that checking for cancellation is more elegant than anything I’ve come across for NSInvocationOperation.

So, for those who have more NSOperations under their belt, which have you used to the most successful end? Is there a nice cancellation solution using NSInvocationOperations that I may have missed? Without some sort of support for cancellation, the number of situations where NSInvocationOperations are useful just went off a cliff.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T17:42:42+00:00Added an answer on May 20, 2026 at 5:42 pm

    just subclass NSOperation. (more characters required)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a fairly simple block of code. Sub Run(Name) on error resume next
I have a fairly simple python loop that calls a few functions, and writes
I have a fairly simple set of functionality for which I have multiple implementations,
I have a fairly simple class that I want to save to SQL Server
I have a fairly simple data audit web application written with ASP MVC which
I have a fairly simple web application that gets a list of items from
I have the following fairly simple code, where I need to determine if a
I have a fairly simple page that displays an image in a pop-up window.
I have a fairly simple CRUD web application (C#/ASP.NET) that runs fine in Firefox,
I have what seems to be a fairly simple scenario that I am trying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.