- Hide quoted text -
On Thu, Aug 18, 2011 at 3:51 PM, Miguel de Icaza <[email protected]> wrote:
> Hello,
>
>> I have this code running on both iPad 1 and 2's. On the iPad 1 the code
>> hangs
>> at random points getting files. On a 2 it works 100% of the time. Any
>> thoughts would be appreciated.
>>
>> WebClient wc = new WebClient();
>> Uri uri = new Uri(url);
>> byte[] bytes = wc.DownloadData(uri);
>>
>> string path = Path.Combine(tmpPath, fileName);
>>
>> File.WriteAllBytes(path, bytes);
>> wc.Dispose();
>
> We just fixed this problem.   Gonzalo (CCed on this line) might be able to
> provide a temporary workaround to use for this scenario.

When the problem occurs, "kicking" the threadpool by adding another
work item will make the problem go away.

Something like this (not tested or compiled ;-) should do:
################################################
Timer timer = new Timer (AddMe);
...
WebClient wc = new WebClient ();
Uri uri = new Uri(url);
timer.Change (0, 500); // Trigger it now and every 500ms
byte[] bytes = wc.DownloadData(uri);
timer.Change (Timeout.Infinite, Timeout.Infinite);
....
static void AddMe (object state)
{
     // Empty.
}
################################################


-Gonzalo
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to