Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/vim/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xamarin.ios WebClient和SOAP调用在MonoTouch 4.0.0和4.0.1中锁定。在第3.2.6节中工作。内部演示。什么';是什么原因造成的?_Xamarin.ios - Fatal编程技术网

Xamarin.ios WebClient和SOAP调用在MonoTouch 4.0.0和4.0.1中锁定。在第3.2.6节中工作。内部演示。什么';是什么原因造成的?

Xamarin.ios WebClient和SOAP调用在MonoTouch 4.0.0和4.0.1中锁定。在第3.2.6节中工作。内部演示。什么';是什么原因造成的?,xamarin.ios,Xamarin.ios,我的应用程序大量使用Web服务调用。最近,一些电话被卡住了。在玩了一番之后,我发现 主要发生在发布版本中 发生在模拟器和设备上(iPad、iOS 4.3) 在iPad1上发生的频率比在iPad2上更高 它不仅限于SOAP中的web服务,还影响System.Net.WebClient 如果手动调用,不会影响[NSString stringWithContentsOfUrl:],因为未绑定 其结果是设备的CPU负载降至零。内存是稳定的(在我的演示项目8.5MB中)。如果我将Console.Wri

我的应用程序大量使用Web服务调用。最近,一些电话被卡住了。在玩了一番之后,我发现

  • 主要发生在发布版本中
  • 发生在模拟器和设备上(iPad、iOS 4.3)
  • 在iPad1上发生的频率比在iPad2上更高
  • 它不仅限于SOAP中的web服务,还影响System.Net.WebClient
  • 如果手动调用,不会影响[NSString stringWithContentsOfUrl:],因为未绑定
其结果是设备的CPU负载降至零。内存是稳定的(在我的演示项目8.5MB中)。如果我将Console.WriteLines()放在任何地方,我可以看到代码被卡在一个WebClient.Download*()方法中

下面的代码演示了(如果构建的版本使用MT 4.0.1,LLVM关闭或打开并不重要)反复从web下载文件有时在第一次尝试时立即失败,有时在10次之后失败,有时在大约30次下载之后失败。 这完全是随机的。如果你认为它能工作,请关闭应用程序并重新启动,最终它会挂起

当使用MT 3.2.6构建相同的应用程序时,下载会全天进行,不会出现任何问题。打破它是不可能的

安装的MONO是最新的可用版本

机器翻译团队的人能对此发表评论吗

using System;
using System.IO;
using System.Threading;
using System.Net;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;

namespace iOSTest
{
    public class Application
    {
        static void Main (string[] args)
        {
            UIApplication.Main (args);
        }
    }

    // The name AppDelegate is referenced in the MainWindow.xib file.
    public partial class AppDelegate : UIApplicationDelegate
    {
    private Thread oThread;
        // This method is invoked when the application has loaded its UI and its ready to run
        public override bool FinishedLaunching (UIApplication app, NSDictionary options)
        {
            // Make a release build and run on iPad 1 with iOS 4.3.2.
            // Fails after downloading between 1 time and 30 times on MT 4.0.1.
            // It is possible that it seems to work. Then just kill the app and restart and suddenly the effect
            // will become visible. If you watch it with Instruments, CPU suddenly drops to zero. The app then is
            // stuck somewhere inside WebClient. After about 10 minutes, an exception will be thrown (timeout).
            // Never fails on MT 3.2.6
            Console.WriteLine(MonoTouch.Constants.Version);

            // A label that counts how often we downloaded.
            UILabel oLbl = new UILabel(new System.Drawing.RectangleF(40, 100, 150, 30));
            window.AddSubview(oLbl);

            // This thread downloads the same file over and over again.
            // The thread is not required to demonstrate the issue. The same problem occurs
            // if the download is running on the main thread.
            this.oThread = new Thread(delegate()
            {
                using(var oPool = new NSAutoreleasePool())
                {
                    int i = 0;
                    while(true)
                    {
                        // Setup webclient and download a file from my website (around 2.4 MB)
                        WebClient oClient = new WebClient();
//将其挂在您自己的URL上,将我从所有流量中解救出来,这将是一件好事。
下载文件(新Uri(“http://www.wildsau.net/image.axd?picture=2011%2f4%2fDSC05178.JPG),Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal),“test.jpg”)


承诺在下一个主要版本中由Xamarin修复。但在4.0.4中仍然不起作用。

来自Gonzalo-

当问题发生时,通过添加另一个线程池来“踢”线程池 工作项将使问题消失

类似这样的东西(未测试或编译;-)应该可以:

    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.
    }
#
工作100%的时间-至少对我来说-YMMV。它做到了,一旦我们把代码置于压力之下(有很多文件要下载),它又停止了。刚刚从MT那里听说4.0.6将有补丁。本周晚些时候应该会看到

昨天和杰夫谈过了。看起来4.0.0和4.0.1中存在问题。它将在4.0.2中固定。似乎已经引入了一些网络问题。是的,听起来与此类似:仍然无法在4.0.5中工作。还没有尝试过alpha 4.1…我只是尝试使用MT 4.0.4.1和MonoDevelop 2.8 alpha,到目前为止,我已经下载了100次测试文件,没有崩溃。但我在iPad2上运行iOS5Beta5。它在运行iOS 4.3的iPhone 4上立即崩溃:-(我将尝试一下4.1测试版和4.9 alpha。它最终看起来在4.1中得到了修复!我已经在我的iPhone4上用iOS 4.3成功地测试了它。有趣的是:在iOS 5测试版5上,即使是4.0.4.1也能工作,但在iOS 4.3中仍然崩溃。万岁!在我们发布修复程序时,上面的代码只是一个变通方法。真正的修复程序几天前被推到了Mono上。)并且将出现在即将推出的MonoTouch版本中(>4.0.5)。
    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.
    }