我突然在我的控制台日志中运行了数百条这样的行,运行一个使用我实现的进度控制器的进程:
** __NSAutoreleaseNoPool(): Object 0x7afafd0 of class NSCFString autoreleased with no pool in place - just leaking
** __NSAutoreleaseNoPool(): Object 0xd8ca4a0 of class __NSCFData autoreleased with no pool in place - just leaking
Run Code Online (Sandbox Code Playgroud)
我在iPhone模拟器上处于多线程环境中,使用WebClient()从Web下载文件.我很困惑如何解决这个问题,因为我不知道是什么原因导致这个问题.正在运行下载的线程嵌入
using ( var oAutoRelease = new NSAutoreleasePool ( ) )
Run Code Online (Sandbox Code Playgroud)
我附加到WebClient的DownloadProgressChanged
方法,在那里我调用一个更新进度视图的委托.如果我删除此行,则警告消失:
ProgressInfo(ACTION.ReceivingResponse, e.ProgressPercentage);
Run Code Online (Sandbox Code Playgroud)
轮流调用代理将返回我的进度控制器并更新标签:
// iIndicator = the value of e.ProgressPercentage.
oProgressController.CurrentActivity = "Percentage done: " + iInidicator.ToString ( ) + "%";
// ProgressController.CurrentActivity:
this.InvokeOnMainThread(delegate { this.oLblCurrentActivity.Text = value; });
Run Code Online (Sandbox Code Playgroud)
我在这里错过了什么!?
编辑:我发现我必须放置另一个NSAutoReleasePool() this.InvokeOnMainThread(delegate { this.oLblCurrentActivity.Text = value; });
但为什么?整个事情已经在一个单独的池中.
小智 7
这个链接可以帮助你http://blog.datispars.com/tasks-in-background-thread-cocoa-performselectorinbackground/ 每个线程都应该拥有自己的自动释放池
归档时间: |
|
查看次数: |
4498 次 |
最近记录: |