Sunday, 18 August 2013

A method inside async bock is not being called

A method inside async bock is not being called

My code is like below, I am trying ot call a cpu intensive method inside
an async block, but that method is not being always called, sometimes it's
called, sometimes not.
-(IBAction) aMethod
//some code
dispatch_async(backgroundQueue, ^{
NSArray *allFiles = [appDel getAllFiles];
totalFilesCount = [allFiles count];
});
//some code
}
The method getAllFiles is sometimes called and sometimes not (checked with
breakpoints), the reason I am calling it into a dispatch_async block is
that it took a lot of time to return the result. What seems to be wrong
with my approach, should it be called in the main thread although it's cpu
intensive method?

No comments:

Post a Comment