Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

dispatch_queue_t In C# ?

$
0
0

Hey

I am completely new to iOS and Xamarin. I am busy working through a tutorial to try learn about UICollectionView(http://www.raywenderlich.com/22324/beginning-uicollectionview-in-ios-6-part-12) and at the same time I am practicing converting Objective C to C#.

There are files in the tutorial not relevant to the Collection View itself, so they are just included and I am trying to convert them to C# but I am stuck.

Here is an excerpt from the code I am trying to convert:

NSString *searchURL = [Flickr flickrPhotoURLForFlickrPhoto:flickrPhoto size:size];

dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);  

dispatch_async(queue, ^{

    NSError *error = nil;

    NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:searchURL]
                                              options:0
                                              error:&error];
    if(error)
    {
        completionBlock(nil,error);
    }
    else
    {
        UIImage *image = [UIImage imageWithData:imageData];
        if([size isEqualToString:@"m"])
        {
            flickrPhoto.thumbnail = image;
        }
        else
        {
            flickrPhoto.largeImage = image;
        }
        completionBlock(image,nil);
    }

});

Without worrying too much about what it does, I am more stuck at the way you are meant to implement dispatch_queue_t and dispatch_async in C# ?

Any assistance appreciated.


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>