Guys
do you see any risk in this method to read an ALAsset synchronously ?
cheers
public static ALAsset SynchronousGetAsset(string filename)
{
ManualResetEvent waiter = new ManualResetEvent(false);
NSError error = null;
ALAsset result = null;
Exception exception;
ThreadPool.QueueUserWorkItem ((object state) => {
assetsLibrary.AssetForUrl (new NSUrl (filename),
(ALAsset asset) => {
result = asset;
waiter.Set ();
},
(NSError e) => {
error = e;
waiter.Set ();
});
});
if(!waiter.WaitOne (TimeSpan.FromSeconds (10)))
throw new Exception("Error Getting Asset : Timeout, Asset=" + filename);
if (error != null)
throw new Exception (error.Description);
return result;
}