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

  • Home
  • SEARCH
  • 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 9184499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:04:08+00:00 2026-06-17T19:04:08+00:00

Wondering if I’m implementing the below method correctly because isCancelled is not canceling the

  • 0

Wondering if I’m implementing the below method correctly because isCancelled is not canceling the thread. I have an image that I’m scaling, and when it’s done scaling, this method is called to update the image. So when the user lifts their finger off the button, this is called. If they try to push the button again before this is finished, I call cancelAllOperations on the queue but it’s not working. Not even sure if cancelAllOperations triggers a flag, or if I need to keep calling it to get a result. Anyone have any insight on this?

- (void) refreshImage
{
    NSBlockOperation *operation = [[NSBlockOperation alloc] init];
    __unsafe_unretained NSBlockOperation *weakOperation = operation;

    [operation addExecutionBlock:
     ^{
         UIImage *image = [[self.graphicLayer imageForSize:self.size] retain];
         if (![weakOperation isCancelled])
         {
             [[NSOperationQueue mainQueue] addOperationWithBlock:
              ^{
                  self.image = image;
                  [image release];
              }];
         }
         else
         {
             [image release];
             return;
         }
     }];

    [self.queue addOperation: operation];
    [operation release];
}
  • 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-06-17T19:04:10+00:00Added an answer on June 17, 2026 at 7:04 pm

    Found the problem, have to replace:

    __unsafe_unretained NSBlockOperation *weakOperation = operation;
    

    with:

    __block NSBlockOperation *weakOperation = operation;
    

    BTW, for anyone interested there is a good video on concurrency, in particular drawing on a separate thread and using NSOperationQueue‘s in WWDC2012 called Building Concurrent User Interfaces on IOS.

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

Sidebar

Related Questions

Wondering what are the views on this We have a CI server that runs
wondering if anybody knows the reason that on android 2.3.5 the -webkit-animation-fill-mode:forwards; does not
Wondering if someone can answer something that has stumped me. I have a Timer
wondering if there's any way to make it so that a list I have
Wondering if I'm going about this the right way or not. I have 3
Wondering if any of you can help me: I've made a signup modal that
Wondering if someone could help me. I have next to no knowledge with Ajax,
Wondering if there is any way to get the lambda expressions that result from
Wondering if anyone can suggest a good file replication tool that will replicate across
Wondering if there is a good way to generate temporary URLs that expire in

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.