草庐IT

article_time

全部标签

swift - generateCGImagesAsynchronouslyForTimes 有时不会生成整个缩略图

我正在开发一个使用AVAssetImageGenerator.generateCGImagesAsynchronouslyForTimes的OSX应用程序,它通常运行良好。然而,有时我得到的缩略图只包含前几行像素,其余的都是绿色,有时图像会呈现不同深浅的绿色。很难追踪到,因为它不会一直发生,但是当它发生时,大约一半的缩略图会受到影响。这是我希望看到的图像:但这种情况经常发生:这是我用来生成缩略图的代码:letassetGenerator=AVAssetImageGenerator(asset:AVURLAsset(URL:url))assetGenerator.appliesPrefe

objective-c - dispatch_time 和 dispatch_walltime 之间有什么区别,在什么情况下使用其中一种更好?

我知道dispatch_time是根据设备时钟确定的时间,如果设备进入休眠状态,时钟也会休眠。另一方面,dipatch_walltime是根据挂钟计算的时间,它永远不会休眠。我的问题是,在不同情况下使用一种或另一种,在性能方面或其他方面有什么区别吗?有人可以给我更多详细信息吗,因为Apple文档并不详尽。例如,我正在编写一个按特定时间间隔运行的Timer类。余地也可以是10到30秒。在性能方面,我应该使用dispatch_time还是dispatch_walltime哪一个。 最佳答案 dispatch_time在您的计算机进入休眠

swift 3.0 : Convert server UTC time to local time and vice-versa

我想将服务器UTC时间转换为本地时间,反之亦然。这是我的代码..varisTimeFromServer=truevartime:String!varperiod:String!lettimeString="6:59AM"//CurrentUTCtimeifisTimeFromServer{letindex=timeString.index(timeString.startIndex,offsetBy:5)lettwelve=timeString.substring(to:index)vardateString:String!letdateFormatter=DateFormatter(

time - 在 Swift 中获取 Unix 纪元时间

在Swift中如何从纪元获取秒数? 最佳答案 您可以简单地使用NSDate的timeIntervalSince1970函数。lettimeInterval=NSDate().timeIntervalSince1970 关于time-在Swift中获取Unix纪元时间,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/25096602/

c# - 为什么 Resharper 使用此代码说 "Co-variant array conversion from string[] to object[] can cause run-time exception on write operation"?

这个问题在这里已经有了答案:Co-variantarrayconversionfromxtoymaycauserun-timeexception(7个答案)关闭7年前。这段代码:comboBoxMonth.Items.AddRange(UsageRptConstsAndUtils.months.ToArray());publicstaticListmonths=newList{"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};提示“从string[]到object[]的Co-variant数

c# - "A connection attempt failed because the connected party did not properly respond after a period of time"使用 WebClient

我正在使用以下在本地机器上运行的代码,但是当我在服务器上尝试相同的代码时它会抛出错误Aconnectionattemptfailedbecausetheconnectedpartydidnotproperlyrespondafteraperiodoftime,orestablishedconnectionfailedbecauseconnectedhosthasfailedtorespond这是我的代码:WebClientclient=newWebClient();//Addauseragentheaderincasethe//requestedURIcontainsaquery.//

c# - 迷你 MVC 探查器 : appears to be displaying profile times for every static resource

我刚刚开始使用mvc-mini-profiler(http://code.google.com/p/mvc-mini-profiler/),我认为它很棒。但是,我在使用它时遇到了一些奇怪的行为。我有一个在IIS7.5上运行的ASP.NETWebforms站点,出于某种原因,当我在启用探查器的情况下加载页面时,我不仅获得了aspx页面的时间测量值,而且还获得了页面上的随机css和js资源。aspx配置文件工作正常,SQL查询的配置文件也正确。然而,如图所示,我还得到了一堆其他结果,这些结果似乎是静态CSS和JS文件的结果。据我所知,这些是由IIS静态提供的,因此甚至不应该为这些调用探查器

c# - 如何在 .NET 4.5 中运行这两种方法 'at the same time'?

我有一个方法可以执行2个独立逻辑block。我希望我可以同时运行它们..只有在这两个子方法都完成后才能继续。我试图了解async/await语法,但我就是不明白。代码如下:publicPewPewSomeMethod(Foofoo){varcats=GetAllTheCats(foo);varfood=GetAllTheFood(foo);returnnewPewPew{Cats=cats,Food=food};}privateIListGetAllTheCats(Foofoo){//Dostuff,likehittheDb,spinaround,dance,jump,etc...//

c# - 可选参数 "must be a compile-time constant"

我有一个分为两个部分文件的类,如下所示:publicpartialclassPersonRepository:BaseRepository{publicstaticreadonlystringColumnID="ID";...和publicpartialclassPersonRepository:BaseRepository{publicListGetByCompany(intcompanyID,stringsortExpression=ColumnID){...但是编译器一直说sortExpression“必须是一个编译时常量”。对我来说,这似乎是一个完美的编译时常量,所以我不明白问

c# - C#中有 "try to lock, skip if timed out"操作吗?

我需要尝试锁定一个对象,如果它已经被锁定就继续(超时后,或者没有它)。C#lock语句是阻塞的。 最佳答案 Ed为您提供了合适的功能。只是不要忘记调用Monitor.Exit()。您应该使用try-finallyblock来保证正确清理。if(Monitor.TryEnter(someObject)){try{//useobject}finally{Monitor.Exit(someObject);}} 关于c#-C#中有"trytolock,skipiftimedout"操作吗?,我们